AI Hints
Home›TypeScript Tutorial›Cheat Sheets and Interviews
TypeScript · Lesson 116 of 120

Cheat Sheet: Advanced

The essentials.

⏱ 2 min read▶ Video at 1:31:55🎓 Free
Watch this lesson in the TypeScript courseWatch on YouTube ↗Full TypeScript course

And here's the advanced page. Generics, type operators, and utility types.

Cheat Sheet: Advanced
From the video: Cheat Sheet: Advanced
  • 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.

TopicSyntax
Generics<T extends { id: number } = Bike>
keyof / typeofkeyof T, typeof value
IndexedT["price"], T[number]
Mapped{ [K in keyof T]: boolean }
ConditionalT extends U ? X : Y
UtilitiesPartial, 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.

keyvalue
satisfiescheck, keep exact
Brandsno id mix-ups
readonlyno changes
Zodoutside 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