Enums vs. Union Types

What

In many cases, an enum can be replaced by a union of string or number literals.

How

Compare these two identical concepts:

// Enum
enum Suit { Hearts, Spades }

// Literal Union
type Suit = "Hearts" | "Spades";

Why

Union types are often preferred because they add zero code to your runtime bundle and are less verbose to define. While enums are slightly easier to refactor across a large codebase, unions provide a cleaner, more idiomatic TypeScript experience that aligns better with how JavaScript itself handles strings and numbers.

Summary

For most modern TypeScript applications, literal union types are the recommended choice over enums unless you specifically need numeric reverse mapping.