Advanced TypeScript Patterns
Design types that catch real bugs, and keep them readable enough that your team still trusts them.
- 4.9 (861 ratings)
- 6,850 learners
- Advanced
- 6h 45m total
- Updated July 2026
What you’ll learn
- Model domain states with discriminated unions and literal types
- Design generic APIs that infer the right types without annotations
- Write mapped, conditional and template literal types with restraint
- Brand IDs and money, and make switch statements exhaustive
- Parse untrusted data into trusted types at the boundary
- Ship strict tsconfigs, declaration files and incremental migrations
Who it’s for
You already write TypeScript: interfaces, unions, a few generics. This course is about the next step, using the type system as a design tool. You will model domain states so impossible ones cannot be written, steer generic inference instead of fighting it, and write type-level code (mapped, conditional and template literal types) that your teammates can still read.
Every lesson builds the type layer of Cartwheel's checkout API client: money that cannot mix currencies, order statuses the compiler checks exhaustively, a fetch client typed from a route map, and parsers that turn untrusted JSON into trusted types. You finish with the parts that ship: strict tsconfig flags, declaration files, explicit resource management, decorators, and a plan for migrating a JavaScript codebase.
- Who it’s for
- Developers who use TypeScript every day and want types that prevent bugs instead of types that only describe code.
- Before you start
- Comfortable with modern JavaScript and everyday TypeScript: annotations, interfaces, unions and basic generics.
Hands-on practice
- Type-level challenges checked by the real TypeScript compiler.
- Guided exercises: spot the bug, fill the command, order the steps.
Course content
5 sections · 22 lessons · 6h 45m total
- Types That Earn Their Keep12 min
- Structural Typing and Assignability17 min
- Narrowing and Control-Flow Analysis20 min
- Discriminated Unions for Domain States19 min
- Literal Types, as const and satisfies18 min
- Section checkpoint5 questions
- Generics as Relationships18 min
- How Inference Works, and const Type Parameters20 min
- Controlling Inference: NoInfer, Defaults and Overloads17 min
- Designing a Typed API Client22 min
- Section checkpoint5 questions
- keyof, typeof and Indexed Access Types16 min
- Mapped Types and Key Remapping19 min
- Conditional Types, Distribution and infer22 min
- Template Literal Types17 min
- Recursive Types and Knowing When to Stop20 min
- Section checkpoint5 questions
- Branded Types and Exhaustive Checks19 min
- Result Types for Expected Failures18 min
- Parsing Untrusted Data at the Boundary20 min
- Type-Safe Event Emitters and Builders21 min
- Section checkpoint5 questions
- tsconfig Strictness That Pays Off19 min
- using Declarations and Standard Decorators17 min
- Declaration Files and Module Augmentation16 min
- Migrating JavaScript to TypeScript, and Keeping It Fast18 min
- Section checkpoint5 questions
Your instructor

Daniel Okafor
Staff Engineer · Brightline
- 4.7 instructor rating
- 12,450 learners
- 2 courses
Daniel wrote iOS apps in Objective-C, then Swift, for six years before joining Brightline's platform team, where he now owns the shared TypeScript libraries that 40 product engineers build on. Both jobs taught him the same lesson: a good type system catches the bug before the customer does.
What learners say
4.9
861 ratings
Jonas Becker
7 months ago
The lesson on discriminated unions changed how I model order states at work. The next sprint, we deleted a whole class of "impossible" checkout bugs.
Mariam Al-Otaibi
4 months ago
I finally understood conditional types and infer by writing them instead of reading about them. The type-test exercises with Expect<Equal<…>> are addictive.
Arjun Mehta
last month
Dense in the best way. The recursive types lesson moved too fast for me and I read it twice, but branded types and NoInfer alone were worth the price.