Why TypeScript Enums Are Dead

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

Node.js v22.6.0+ introduced native TypeScript support through type-stripping, but traditional enums break this workflow because they require code transformation rather than simple type erasure. The solution is using 'as const' objects or type unions instead, which provide the same functionality while remaining fully compatible with Node's erasable-only approach. TypeScript 5.8's --erasableSyntaxOnly flag helps catch compatibility issues during development.

4m read timeFrom typescript.tv
Post cover image
Table of contents
ContentsThe Type-Stripping RevolutionThe Enum ProblemThe Modern AlternativeWhen to Use Type UnionsCatching Errors at Compile Time

Sort: