Docs
/
TypeScript
Chapter 12
12 — Utility Types
Core Concepts
Built-in utility types transform existing types without rewriting them.
| Utility | What It Does |
|---|---|
Partial<T> | All properties optional |
Required<T> | All properties required |
Readonly<T> | All properties readonly |
Pick<T, K> | Keep only specified keys |
Omit<T, K> | Remove specified keys |
Record<K, V> | Object with keys K and values V |
Exclude<U, E> | Remove types from a union |
Extract<U, E> | Keep only matching types from a union |
NonNullable<T> | Remove null and undefined |
ReturnType<F> | Extract return type of a function |
Parameters<F> | Extract parameter types as a tuple |
Awaited<T> | Unwrap Promise type |
ConstructorParameters<C> | Extract constructor param types |
InstanceType<C> | Extract instance type from class |
When to Use
- Partial — update functions, optional config overrides
- Pick/Omit — API response shaping, DTO patterns
- Record — dictionaries, lookup maps
- ReturnType/Parameters — deriving types from existing functions