Discriminated Union
Noun · Development
Definitions
A union type where each member has a common literal property (the discriminant) that allows the type checker to narrow which variant is in use. Also called a tagged union or algebraic data type.
In plain English: A value that can be one of several shapes, but always carries a label telling you which shape it currently is.
Example: "We model API responses as a discriminated union — { status: "ok", data } | { status: "error", message } — so TypeScript narrows automatically."
Related Terms
- Declaration File
- Effect System
- Error Union
- Generics
- Implicit
- Multiple Dispatch
- Option Type
- Optional
- Pattern Matching
- Pipe Operator
- Predicate
- Proc
- Pure Function
- Reduction
- Tail Call
- Type Class
- Type Guard
- Union Type
- Utility Types
- Variant
- Algebraic Data Type
- Type Erasure
- Memoization
- Referential Transparency
- Pattern Guard
- Continuation
- Structural Typing
- Effect System
- Applicative Functor
- Lens
- Partial Application
- Algebraic Effects
- Partial Type
- Record Type
- Type Predicate
- Utility Type
- Zod