Course contentsShow
← TypeScript
Lesson 413 of 1,7969. Union TypesFree lesson

Common Discriminant Names

Conventions like 'type', 'kind', 'tag', or 'status' for discriminant properties.

Common Discriminant Names

What you'll learn: The conventional property names TypeScript developers use to identify which variant of a discriminated union you're working with.

Why Naming Matters

You've learned how discriminated unions work with a unique literal property that distinguishes each variant. But what should you name that property? While technically you can use any name (flavor, variant, category), the TypeScript community has settled on a few conventions that make code more readable and predictable.

The Standard Discriminant Names

The four most common discriminant property names are:

  • type — The most popular choice, especially for modeling different kinds of data structures
  • kind — Similar to type, often used when type feels too generic or conflicts with other naming
  • tag — Common in functional programming circles and compiler design
  • status — Perfect for representing different states of a process or entity

When to Use Which

Use type for general-purpose discriminated unions where you're modeling fundamentally different things (e.g., different event types, different response shapes).

Use kind when you want to be slightly more specific than type, or when working with APIs that already use type for something else.

Use status specifically for state machines or workflow representations where each variant represents a different stage (pending, success, error).

Use tag when you want to emphasize the discriminant is just a label, or when following functional programming patterns.

Why Consistency Helps

Following these conventions means other developers can instantly recognize your discriminated unions. When they see type: 'success' or status: 'loading', they immediately understand the pattern you're using, making your code more maintainable.

Key Takeaway: While any property name works technically, using conventional names like type, kind, tag, or status makes your discriminated unions instantly recognizable and easier for teams to work with.