Glossary term
What is discriminated union? Meaning for developers
In Senior Frontend Depth
A union where every variant has a tag property with a fixed value. Checking the tag narrows the type and lets you check all cases.
Learn it properly · Senior Frontend DepthLesson 4: Advanced TypeScript for Interviews: Generics, Narrowing, Utility and Conditional TypesGeneric constraints, discriminated unions, infer, mapped types, satisfies, and keeping API response types correct from the server to the UI.In Full-Stack Questions
A union of object types that share one field (the tag) with a different literal value in each. Checking the tag narrows the type.
Learn it properly · Full-Stack QuestionsLesson 3: TypeScript Interview QuestionsGenerics, narrowing, utility types, tsconfig flags, typing React and APIs, and the errors that confuse people.In TypeScript From Zero
A union of object types that share a literal field, such as kind, which tells them apart.
Learn it properly · TypeScript From ZeroLesson 1: Basic Types, Inference and NarrowingPrimitives, unions, literal types, any versus unknown versus never, inference, narrowing and discriminated unions.