We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native TypeScript enums are exclusive union of each members.
enum
enum Fruit { Apple, Orange } type T = Fruit.Apple & Type.Orange // never
This allows type interpretations in some use-cases to be useful:
declare const fruit: Fruit; if (fruit === Fruit.Apple) { ... } if (fruit === Fruit.Orange) { ... } // now, compiler knows this code is not reachable
declare const fruit: Fruit; switch (fruit) { case Fruit.Apple: { ..., break; } case Fruit.Orange: { ..., break; } // now, compiler knows this code is not reachable }
Allow this functionality to extended enums, so that the following holds:
enum _Fruit { Apple, Orange } const Fruit = extend<typeof _Fruit, _Fruit>(_Fruit); type T = Fruit.Apple & Fruit.Orange; // never
Also, the extended enum class itself and the members should be type and value at the same time, like the native enum does.
type T = Fruit.Apple extends Fruit ? true : false // true enum _Vegetable { Potato, Celery } const Vegetable = extend<typeof _Vegetable, _Vegetable>(_Vegetable); type U = Vegetable.Potato extends Fruit ? true : false // false
The text was updated successfully, but these errors were encountered:
The exclusivity of instance types are implemented in #22. The next goal is to make the union of instance types to exhaustively define the whole type.
Sorry, something went wrong.
inhibitor1217
No branches or pull requests
Native TypeScript
enum
s are exclusive union of each members.This allows type interpretations in some use-cases to be useful:
Allow this functionality to extended enums, so that the following holds:
Also, the extended enum class itself and the members should be type and value at the same time, like the native
enum
does.The text was updated successfully, but these errors were encountered: