Type alias InferValue<T>

InferValue<T>: EnumToUnion<ReturnType<T["values"]>[number]>

Utility type to infer type of value for a simple or labeled enum.

Type Parameters

Example

const STATUSES = Enum(['on', 'off']);
type Status = InferValue<typeof STATUSES>; // Status is 'on' | 'off'

const LOCALES = Enum({ English: 'en', Czech: 'cs', Slovak: 'sk' });
type Locale = InferValue<typeof LOCALES>; // Locale is 'en' | 'cs' | 'sk'

Generated using TypeDoc