Back to Course
Printable Cheat Sheet
ToolMate Technical Interview Revision Deck • TypeScriptUpdated 2026
TypeScript Type System & Advanced Generics Cheat Sheet
Conditional types, Mapped types, infer keyword, utility types & discriminating unions.
Top Interview Golden Rules & Senior Principles
- Favor Discriminated Unions with a shared literal tag (e.g., type: 'success' | 'error') over optional nullable flags.
- Avoid 'any': use 'unknown' when type is uncertain, requiring type narrowing with type guards before usage.
- Use 'satisfies' operator to validate that an expression matches a type without widening its specific inferred type.
- Use 'const assertions' (as const) to preserve exact literal types and mark arrays/objects as deeply readonly.
- Use 'keyof' and 'typeof' to extract property names and structural types from runtime objects.
Advanced Utility & Conditional Types
Conditional Types with 'infer'
type ReturnType<T> = T extends (...args: any[]) => infer R ? R : any;
Extracts an embedded type parameter dynamically from a function signature or promise.
Mapped Types & Key Remapping
type Getters<T> = { [K in keyof T as `get${Capitalize<string & K>}`]: () => T[K] }Transforms property names and types programmatically across an interface.
Exclusion & Extraction
Exclude<T, U> vs Extract<T, U>
Exclude removes assignable union members; Extract selects matching union members.
ToolMate Interview Prep • https://interview.toolmate.co.in • Free for personal study & interview preparation