/** * These are the valid value types to use with the enum; enum must use a string * indexor but the value can be any of these types: */ declare type ValidEnumTypes = number | string | boolean; /** * Use this along with TypeFromEnum to make a "fake" frozen enum which can be * used in place of an enum in ways that are mongoose-friendly and much more * flexible than a typescript enum. Example: * * const MyEnum = MakeEnum({ * key1: "value1", * key2: "value2", * key3: "value3", * }); * type MyEnum = TypeFromEnum; * * // MyEnum will be type 'value1' | 'value2' | 'value3' * // MyEnum.key1, etc al work * // Object.values(MyEnum) will return ["value1", "value2", "value3"] e.g. for use in a mongoose enum * // assigning something of type MyEnum to the string value works * * You can also pass in multiple objects (or multiple enums created with this * helper) and the result will combine them with the actual value using Object.assign * * @param x Enum object to create a typed enum for */ declare function MakeEnum(x1: T1): Readonly; declare function MakeEnum(x1: T1, x2: T2): Readonly; declare function MakeEnum(x1: T1, x2: T2, x3: T3): Readonly; declare function MakeEnum(x1: T1, x2: T2, x3: T3, x4: T4): Readonly; declare function MakeEnum(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5): Readonly; declare function MakeEnum(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6): Readonly; declare function MakeEnum(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7): Readonly; declare function MakeEnum(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8): Readonly; declare function MakeEnum(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9): Readonly; /** * Use this with MakeEnum. See docs for MakeEnum for example */ declare type TypeFromEnum = (T)[keyof T]; export { MakeEnum, TypeFromEnum };