enumify-ts
Version:
A JavaScript library that helps with the enum pattern based on TypeScript. This fork of [rauschma/enumify](https://github.com/rauschma/enumify) permits to infer the correct type from constructed collections: for example, the type of `values()` will be `A
18 lines (17 loc) • 527 B
TypeScript
export declare function Enumify<T>(): {
new (): {
_key: string;
_ordinal: number;
readonly key: string;
readonly ordinal: number;
toJSON(): string;
toString(): string;
};
_instances: Record<string, T>;
readonly keys: string[];
readonly values: T[];
_closeEnum(callback?: (() => void) | undefined): void;
valueOf(str: string): undefined | T;
[Symbol.iterator](): IterableIterator<T>;
fromString(str: string): undefined | T;
};