/** * Defines a scalar enum as a type from its constructor. * * @example * ```ts * enum Direction { Left, Right }; * type DirectionType = ScalarEnum; * ``` * * @category Utils */ export type ScalarEnum = { [key: number | string]: string | number | T; } | number | T; /** * Defines a data enum using discriminated union types. * * @example * ```ts * type WebPageEvent = * | { __kind: 'pageview', url: string } * | { __kind: 'click', x: number, y: number }; * ``` * * @category Utils */ export type DataEnum = { __kind: string; }; /** * Extracts a variant from a data enum. * * @example * ```ts * type WebPageEvent = * | { __kind: 'pageview', url: string } * | { __kind: 'click', x: number, y: number }; * type ClickEvent = GetDataEnumKind; * // -> { __kind: 'click', x: number, y: number } * ``` * * @category Utils */ export type GetDataEnumKind = Extract; /** * Extracts a variant from a data enum without its discriminator. * * @example * ```ts * type WebPageEvent = * | { __kind: 'pageview', url: string } * | { __kind: 'click', x: number, y: number }; * type ClickEvent = GetDataEnumKindContent; * // -> { x: number, y: number } * ``` * * @category Utils */ export type GetDataEnumKindContent = Omit, '__kind'>;