Get the latest tech news
TypeScript enums: use cases and alternatives
In this blog post, we take a closer look at TypeScript enums: How do they work? What are their use cases? What are the alternatives if we don’t want to use them? The blog post concludes with recommendations for what to use when.
The as const in line A enables us to derive ActivationType from Activation via the helper type PropertyValues(which is defined below). Alas, that’s a current limitation of as const for symbols: They are not recognized as unique ( related GitHub issue): We could change that by using symbols but then we’d lose some of the convenience of string literal union types – e.g., we’d have to import the values.
Or read this on Hacker News