Community Preference for Unions
You'll learn: Why TypeScript experts generally recommend string literal unions over enums, and what makes unions the preferred choice in modern codebases.
The Community Consensus
If you browse popular TypeScript style guides, open-source projects, or ask experienced TypeScript developers, you'll notice a clear pattern: string literal unions are heavily preferred over enums. This isn't just personal taste—there are concrete technical reasons behind this recommendation.
Why Unions Win the Popularity Contest
Zero runtime cost: String literal unions exist only at compile time. They compile away completely, leaving just your raw string values in the JavaScript output. Enums, by contrast, generate runtime objects that add to your bundle size.
Simpler mental model: A union like "success" | "error" | "pending" is exactly what it looks like—a choice between strings. No reverse mappings to remember, no namespace pollution, no surprises.
Better interoperability: When working with external APIs, JSON data, or JavaScript libraries, you're already dealing with plain strings. Unions match this reality perfectly, while enums introduce a TypeScript-specific abstraction.
Tree-shakable by default: Since unions don't generate code, there's nothing to tree-shake. With enums, unused members still end up in your bundle unless you use const enums (which have their own problems).
The Practical Recommendation
Most style guides recommend: Use string literal unions as your default. Reserve enums only for cases where you genuinely need the runtime object (rare) or when integrating with legacy code that already uses them.
Key Takeaway: The TypeScript community strongly favors string literal unions over enums because they're simpler, have no runtime cost, and integrate better with JavaScript—use unions as your default choice.