Everyday types and narrowing
Model real data with unions, literals and narrowing.
- TS.02.01Unions, literals and narrowingCoreJuniorBeing written
- TS.02.02Discriminated unions and exhaustive checksCoreMid-level10 min
- TS.02.03User-defined type guards and assertion functionsCoreMid-level10 min
- TS.02.04as const, satisfies and literal inferenceCoreMid-level10 min
- TS.02.05Enums vs union typesJuniorBeing written
Interview questions in this module
- What is a discriminated union? Show how you model a request state.
- How do you make the compiler warn when a new case is not handled?
- What is a type guard? Write one.
- What is the difference between
satisfies, a type annotation andas? - Why might you avoid enums?
- What does
as constdo?