Module · Intermediate · 1h 15m
Module 1: Modelling data
Types that make invalid states unrepresentable, so bugs are caught by the compiler and not by customers.
- typescript
- module
Inside this module
- Model states with discriminated unions
- Use literal types instead of strings
The full module opens with a membership that covers TypeScript.
Sign in if you already subscribe.
Sign inLessons
- 01Unions over booleans
Lesson · 25 min · Replacing flag combinations with a union of states that cannot contradict each other.
- 02Literal types and const
Lesson · 25 min · Precise types for strings and numbers that are really a fixed set.
- 03Narrowing safely
Lesson · 25 min · Turning unknown and union values into specific ones with guards the compiler understands.

