Type-Level Programming
- Types as functions. Generic conditional types are functions over types: inputs, branching, recursion, all at compile time.
- Recursive types. A recursive type walks nested structures: DeepReadonly visits every property of every child.
- Know the limits. The checker has depth and complexity limits: a type that times out the compiler is a design smell.
API and Library Type Architecture
- Inference-first APIs. The best APIs need no type arguments: design so inference carries the caller the whole way.
- Builder and fluent typing. A typed builder accumulates knowledge step by step, refusing build() until the required parts exist.
- Overload surfaces. Public libraries shape ergonomics with careful overloads: precise returns for each documented call shape.
Balancing Type Safety and Complexity
- The cleverness budget. Every team has a type cleverness budget: spend it where bugs are expensive, not where it is fun.
- Escape hatches, labelled. A justified cast is honest when commented: the assumption named, dated and owned.
- Optimise for the reader. The winning type design is the one a tired colleague reads correctly at review speed.
Before and after this level
- Before: Level 13: Testing & Refactoring: Testing Typed Code, Type-Safe Refactoring, Maintaining Large TypeScript Codebases.
- Next: Level 15: Production TypeScript: Build Performance and Tooling, JavaScript Interoperability, Production Architecture and Reliability.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does TypeScript Level 14: Advanced Type Design cover?
Type-Level Programming, API and Library Type Architecture, Balancing Type Safety and Complexity: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 13: Testing & Refactoring, which covers Testing Typed Code, Type-Safe Refactoring, Maintaining Large TypeScript Codebases.