Suggestion: add generic tagged objects to core library #10882
Labels
Declined
The issue was declined as something which matches the TypeScript vision
Suggestion
An idea for TypeScript
A lot of suggestions have been around nominal typing. A fair share of those are made by people who are pleasantly surprised to discover the tagged interface method. I propose adding @RyanCavanaugh's elegant generic solution to the library (and the documentation!), to help users discover this great feature. It would also avoid every popular Typescript library eventually adding their own version of this. I know I was surprised to find it and I would have loved to discover it sooner.
Example use:
It may be useful to split this into a type and an interface, though this may make it less elegant (and thus overreaching for inclusion in the core library):
It does allow for more advanced uses of this system, such as runtime type checking:
The naming might need some discussion.
The text was updated successfully, but these errors were encountered: