keyof, typeof and Indexed Access
- keyof. keyof turns a type’s property names into a union: keyof User is "id" | "name" | "email".
- typeof. The type-level typeof lifts a value’s type: const config = {...}; type Config = typeof config.
- Indexed access. Indexed access reads one property’s type: User["email"] is string: types queried like data.
Mapped and Conditional Types
- Mapped types. A mapped type rebuilds every property: Partial makes each optional, Readonly locks each one.
- Conditional types. A conditional type branches: T extends string ? A : B: an if statement running inside the type system.
- infer. The infer keyword captures a piece of a matched type: how ReturnType extracts what a function yields.
Template Literal Types
- String types. A template literal type builds string shapes:
on${Capitalize<Event>}names every handler key. - Typed routes and keys. Template literal types check real patterns: route strings and event names verified at compile time.
- Restraint. Type-level string tricks impress but cost: reach for them when they eliminate real bugs, not for sport.
Before and after this level
- Before: Level 5: Generics: Generic Functions and Types, Constraints and Relationships, Designing Reusable Typed APIs.
- Next: Level 7: Classes & Object Design: Classes and Access Modifiers, Abstract Classes and Interfaces, Composition and Typed Domain Models.
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 6: Advanced Type Transformations cover?
keyof, typeof and Indexed Access, Mapped and Conditional Types, Template Literal Types: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 5: Generics, which covers Generic Functions and Types, Constraints and Relationships, Designing Reusable Typed APIs.