collectype

collectype v0.11.0


collectype / types/utility / EnumOrString

Type Alias: EnumOrString<E>

EnumOrString<E> = E[keyof E] | E[keyof E]

Defined in: types/utility.ts:78

Helper type to allow either an enum member or its string value.

Type Parameters

E

E extends Record<string, string>

The enum type (must be a string-valued enum).

Example

enum E { A = 'a', B = 'b' }
type Example = EnumOrString<E>; // 'a' | 'b'