You don't need another TypeScript tutorial. You need a reference you can scan while you're writing code -- one that shows you the exact syntax for generic constraints, utility type composition, and discriminated union patterns without burying it in paragraphs of explanation.
That's what this page is. Each topic below links to a dedicated cheat sheet with copy-ready examples, inline output comments, and notes on the gotchas that trip people up. If you already understand TypeScript's type system conceptually but keep pausing to look up the syntax, you're in the right place.
The exercises complement the cheat sheets. They test whether you can write the patterns from memory -- not just recognize them. Ten minutes of daily practice turns "I think it's something like this" into automatic recall.
For a broader overview covering type narrowing, discriminated unions, and common compiler errors, see the [TypeScript concept page](/javascript/typescript).
Popular topics include TypeScript Generics: Constraints, Defaults & Patterns, TypeScript Utility Types: Partial, Pick, Omit & More, TypeScript Type Narrowing: Guards, Predicates & Patterns.
Built for TypeScript Learners
- TypeScript developers who know the concepts but blank on exact syntax during coding.
- Frontend and full-stack engineers using TypeScript daily who want faster recall.
- Developers preparing for TypeScript-heavy interviews or code reviews.
- Teams adopting TypeScript who need a shared quick-reference resource.
- Write generic constraints without trial and error.
- Compose utility types like Partial, Pick, and Omit from memory.
- Narrow union types confidently using typeof, in, and type predicates.
- Know when to reach for interface vs type without second-guessing.
- Use satisfies, template literal types, and conditional types fluently.
Practice by Topic
Pick a concept and train recall with small, focused reps.
Generics
Stop guessing at generic constraints and write type-safe reusable code on the first try.
Show 3 gotchasHide gotchas
- Constraints use
extends, notimplements:<T extends HasLength>. - Default type parameters go after required ones:
<T, U = string>. - The
keyof+extendspattern is the most common generic pattern in real codebases.
Utility Types
Compose Partial, Pick, Omit, and Record without looking them up every time.
Show 3 gotchasHide gotchas
Partial<T>makes ALL properties optional, not just some -- usePick+Partialfor selective optionality.Omit<T, K>doesn't error on invalid keys -- you can omit keys that don't exist.Record<K, V>creates an index signature, not a fixed-key object.
Type Narrowing
Narrow broad types to specific ones without resorting to type assertions.
Show 3 gotchasHide gotchas
typeof nullis"object"-- always check for null separately.- Closures don't narrow: reassigning a variable inside a callback resets narrowing.
- Custom type guards (
x is T) are the only way to narrow with complex logic.
Interfaces vs Types
Pick the right tool for the job -- interface for extendable objects, type for everything else.
Show 3 gotchasHide gotchas
- Only
interfacesupports declaration merging (adding fields across files). - Only
typecan represent unions, tuples, and mapped types. - For plain object shapes, either works -- consistency matters more than the choice.
Union & Intersection
Build precise types with union and intersection operators without losing type safety.
Show 3 gotchasHide gotchas
- Union (
|) means "one of these." Intersection (&) means "all of these." - Discriminated unions need a shared literal property for narrowing to work.
- Exhaustive checking with
nevercatches missing cases at compile time.
Template Literal Types
Generate string union types dynamically from other types -- no manual duplication.
Show 3 gotchasHide gotchas
- Template literal types produce union combinations: 2 x 3 base types = 6 output types.
- Built-in
Uppercase,Lowercase,Capitalize,Uncapitalizeonly work at the type level. - Complex template literals can slow down the compiler -- keep unions small.
satisfies Operator
Validate object shapes without losing precise inferred types.
Show 3 gotchasHide gotchas
satisfieschecks the type without widening --asoverrides the type entirely.- Works best with
Recordand config objects where you want literal key types preserved. - Available since TypeScript 4.9 -- check your project's TS version.
TypeScript Cheat Sheets
Copy-ready syntax references for quick lookup
Sample Exercises
Write a generic identity function that takes type T and returns T
function identity<T>(x: T): T { return x; }Make all User properties optional for an update payload
Partial<User>Why this works
TypeScript's type system has dozens of utility types, narrowing techniques, and generic patterns. You won't use all of them every day, which means the less common ones fade fast. Spaced repetition keeps the full toolkit fresh so you don't relearn Record syntax every time you need it.
FAQ
The handbook teaches concepts. These cheat sheets are scannable references you use while coding. No long prose blocks -- just syntax, output comments, and gotcha notes. The exercises test recall so the patterns stick without re-reading docs.
Yes. This content assumes you understand what types, interfaces, and generics are. It's for developers who get the concepts but keep forgetting the exact syntax -- not for learning TypeScript from scratch.
Daily usage reinforces the patterns you use often. It doesn't help with the ones you use occasionally -- generic defaults, conditional types, template literal patterns. Those are exactly what spaced repetition targets.
Yes. Every exercise uses TypeScript syntax with type annotations, generics, and utility types. They're graded on TypeScript-specific constructs, not just JavaScript logic.
Content covers TypeScript 5.x features including the satisfies operator (4.9+), const type parameters (5.0+), and current utility type behavior. Examples use modern syntax throughout.