DEV Community

Collabier
Collabier

Posted on

TypeScript tip: Stop using legacy numeric enums in modern applications.

Enums generate unnecessary runtime boilerplate, don't tree-shake cleanly, and often behave unpredictably with Babel or esbuild.

Modern TypeScript codebases favor string union types:
type UserRole = 'admin' | 'editor' | 'viewer';

To make refactoring legacy codebases painless, I built a zero-install converter:
• Paste your TypeScript enum
• Instantly get clean union types and as const object arrays
• 100% in-browser, no data leaves your machine

Tool link: https://omnikite.vercel.app/tools/developer/typescript-enum-to-union-type-converter

How does your team handle enums vs string unions in production?

Top comments (0)