- All Courses
- TypeScript for Application Developers
- How the Type System Thinks
- Unions and narrowing
Unions and narrowing
A discriminated union plus a check on the discriminant is the workhorse pattern of typed application code. Narrowing is how the compiler follows your control flow.
- 10m
- Intermediate

Video by Andrew Burgess · YouTube
Check your understanding
3 questions. Unlocks when you finish the video.
Overview
What this lesson covers
- Model alternatives as a discriminated union
- Narrow with typeof, in, and discriminant checks
- Make a switch exhaustive with a never assertion
This lesson sits in How the Type System Thinks, part of TypeScript for Application Developers. It assumes what came before it and leads directly into the next lesson in the module.
In this lesson you will:
- Model alternatives as a discriminated union
- Narrow with typeof, in, and discriminant checks
- Make a switch exhaustive with a never assertion
Resources
Your notes will live here
Note taking is not available yet. Nothing you type would be saved, so the tab stays read-only for now.