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.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of TypeScript

TypeScript

Photo of alternatives

alternatives

Photo of cases

cases

Related news:

News photo

TikTok Shut Down: Data Shows 85% Drop in US Access (and Surge to Alternatives)

News photo

Node.js 'Type Stripping' for TypeScript Now Enabled by Default

News photo

Best OnePlus 13R cases 2025