TypeScript Utility Types Reference

Complete guide to built-in TypeScript utility types with examples

A complete TypeScript utility types reference covering all built-in mapped and conditional types. Each entry includes syntax, before/after type examples, and typical use cases.

How to Use TypeScript Utility Types

TypeScript's built-in utility types let you transform existing types rather than defining new ones from scratch. They are the foundation of DRY TypeScript code.

Most Used Utility Types

Partial<T> is the most common — use it for update/patch operations where all fields are optional. Pick<T, Keys> and Omit<T, Keys> are used to create focused sub-types from larger interfaces. Record<Keys, Values> is the cleanest way to type dictionaries and lookup maps.

Inferring Types from Functions

Use ReturnType<typeof fn> to infer a function's return type instead of manually defining it. This keeps types in sync automatically when the function changes. Similarly, Parameters<typeof fn> extracts the parameter tuple type, useful for wrapper functions that take the same arguments.

Combining Utility Types

Utility types can be chained: Partial<Pick<User, 'name' | 'email'>> creates a type with only name and email as optional fields. This pattern is common for form update payloads or partial update API request bodies.

Frequently Asked Questions

Is this TypeScript utility types reference free?

Yes, completely free. No account required.

What is the difference between Partial and Required?

Partial<T> makes all properties in type T optional (adds ? to each property). Required<T> is the opposite — it removes the optional modifier from all properties, making them required. These are useful when you have a base type and need variants for creation (all required) vs updates (all optional via Partial).

When should I use Pick vs Omit?

Pick<T, Keys> creates a type with only the specified keys — use it when you want a small subset of a larger type. Omit<T, Keys> creates a type with all keys except the specified ones — use it when you want everything except a few fields. If you're selecting more fields than you're removing, use Omit; otherwise use Pick.

What is the difference between Exclude and Omit?

Exclude works on union types (values), while Omit works on object types (keys). Exclude<'a' | 'b' | 'c', 'a'> returns 'b' | 'c'. Omit<{a: number, b: string}, 'a'> returns {b: string}. Exclude is for filtering union members; Omit is for removing object properties.

How does ReturnType work?

ReturnType<T> extracts the return type of a function type. Example: function getUser() { return { id: 1, name: 'Alice' } } — then type User = ReturnType<typeof getUser> gives you { id: number; name: string }. This is extremely useful for inferring types from factory functions without manually defining the return type.

What is the NonNullable utility type for?

NonNullable<T> removes null and undefined from a type. NonNullable<string | null | undefined> gives string. It is useful when you've narrowed a value and want the type to reflect that it can no longer be null. Commonly used after checking if a value is defined before passing it to a function with a stricter type.