TypeScript · Lesson 116 of 120
Cheat Sheet: Advanced
The essentials.
And here's the advanced page. Generics, type operators, and utility types.

- Generics
- Type operators
- Utility types
Advanced cheat sheet
Generics with constraints and defaults. Keyof, typeof, and indexed access. Mapped and conditional types. And the most used utility types.
| Topic | Syntax |
|---|---|
| Generics | <T extends { id: number } = Bike> |
| keyof / typeof | keyof T, typeof value |
| Indexed | T["price"], T[number] |
| Mapped | { [K in keyof T]: boolean } |
| Conditional | T extends U ? X : Y |
| Utilities | Partial, Pick, Omit, Record, ReturnType |
Safety tools
Use satisfies to check without widening. Brands to stop IDs mixing. Readonly to stop changes. Result types for expected failures. And Zod for outside data.
| key | value |
|---|---|
| satisfies | check, keep exact |
| Brands | no id mix-ups |
| readonly | no changes |
| Zod | outside data |
Summary
Generics, type operators, utilities, and safety tools, on one page. Next, interview questions.
Key takeaways- <T>
- keyof
- Utilities
Next up: TypeScript Interview Questions — ten to know