TypeScript in Depth
The route
- 95 minInference is the point
Letting the compiler do the work, and what an annotation is really for.
You board here - 95 minNarrowing and the discriminated union
Modelling states so the impossible ones will not compile.
- 95 minGenerics that read well
Type parameters and constraints, and knowing when a generic is overkill.
- 95 minThe type-level toolkit
Conditional and mapped types, keyof and template literals — used sparingly, on purpose.
- 95 minTypes at the boundary
Validating what arrives from an API, and where `unknown` beats `any`.
- 95 minConfiguring a real codebase
The strict flags, module resolution, and living with third-party types.
A look at the teaching
Make the impossible state fail to compile.
// Flags let you express nonsense — loading AND an error AND data:
type Bad = { loading: boolean; error?: string; data?: Course };
// A discriminated union cannot:
type State =
| { status: "loading" }
| { status: "error"; message: string }
| { status: "ready"; data: Course };
function render(s: State) {
if (s.status === "error") return s.message; // narrowed
if (s.status === "ready") return s.data.title; // narrowed
return "Loading…";
}
The compiler now refuses the states you would otherwise have to remember not to create. That is worth more than any clever generic you will ever write.
Who is driving
Péter teaches the way a good colleague explains things at a whiteboard — no jargon for its own sake, and nothing hidden behind “as you can see”.
Placeholder profile