← All resources
TypeScript utility types cheat sheet cover with code examples

Programming cheat sheet

TypeScript Utility Types and Patterns Cheat Sheet

A filterable reference for Partial, Pick, Omit, Record and friends, with narrowing, satisfies, generics, and a strict tsconfig baseline.

A working reference for the TypeScript features you reach for every week. Look up any built-in utility type in a filterable table, then see them applied to one realistic model. Learn narrowing with discriminated unions and exhaustive checks, when to use satisfies versus a type annotation, how to write constrained generics, mapped and conditional types, and which tsconfig flags catch the most bugs. Includes a step-by-step typed fetch helper, two quizzes, and a type-safety review checklist. Every sample compiles under strict mode.

A living reference, not a download. Buy once and every update is included. It's currently on version 1, and you read it in your account, always current.

$9.00 · one-time
Sections
7
Code samples
5
Tables
3

Outcomes

What you will be able to do

  • Pick the right utility type without opening the docs
  • Model API results and state with discriminated unions that the compiler checks
  • Use satisfies, as const, and generics with confidence
  • Turn on the tsconfig flags that prevent real production bugs
  • Replace any with unknown and narrow safely

Is this for you?

Made for

  • JavaScript developers moving to TypeScript
  • React and Next.js developers who want stricter, cleaner types
  • Developers who can read TypeScript but struggle to write generics and mapped types

Probably not for

  • Complete beginners who have never written JavaScript
  • Anyone looking for advanced type-level programming puzzles

Free preview

Read a piece before you buy

TypeScript's built-in utility types and a handful of patterns cover most of what real codebases need. This sheet lists each one with a one-line meaning and a runnable example, then shows the narrowing, generics, and tsconfig settings that catch the most bugs.
Use the filter box on the tables to find a utility fast. Every code sample compiles on current TypeScript with strict enabled.

Utility types at a glance

Partial<T>Every property becomes optionalPartial<User>
Required<T>Every property becomes requiredRequired<Config>
Readonly<T>Every property becomes readonlyReadonly<State>
Pick<T, K>Only the listed keysPick<User, "id" | "name">
Omit<T, K>Everything except the listed keysOmit<User, "password">
Record<K, V>An object type with keys K and values VRecord<string, number>
Exclude<U, X>Remove members of a unionExclude<"a" | "b", "a"> // "b"
Extract<U, X>Keep only matching members of a unionExtract<"a" | 1, string> // "a"
NonNullable<T>Remove null and undefinedNonNullable<string | null>
ReturnType<F>The type a function returnsReturnType<typeof fetchUser>
Parameters<F>A tuple of a function's parameter typesParameters<typeof fetchUser>
Awaited<T>Unwrap a Promise, recursivelyAwaited<Promise<string>>
InstanceType<C>The type of instances of a classInstanceType<typeof Map>
Uppercase<S>Uppercase a string literal type (also Lowercase, Capitalize, Uncapitalize)Uppercase<"id"> // "ID"

14 of 14 rows

utility-types.ts
interface User {
  id: string
  name: string
  email: string
  role: "admin" | "member"
}

// A form that edits some fields and leaves the rest alone
type UserPatch = Partial<Pick<User, "name" | "email">>

// Safe to send to the browser
type PublicUser = Omit<User, "email">

// One label for every role, checked for completeness
const roleLabels: Record<User["role"], string> = {
  admin: "Administrator",
  member: "Member",
}

// Derive types from functions instead of rewriting them
async function loadUser(id: string) {
  return { id, name: "Ada", role: "admin" as const }
}
type LoadedUser = Awaited<ReturnType<typeof loadUser>>

The utilities you will use every week, applied to one model.

Questions, answered

Which TypeScript version is this written for?

Current TypeScript with strict mode enabled. The satisfies operator needs TypeScript 4.9 or newer.

Does it cover React types?

It focuses on core language features that apply everywhere, including React projects.

Can I copy the code into my project?

Yes. The samples are meant to be copied and adapted.

A clear reference, ready when you need it.

Purchase unlocks the complete guide in your account, with every future update included. You'll create or sign in to your account at checkout so your access stays attached to you.