TypeScript Utility Types

Every built-in TypeScript utility type — with real usage patterns, examples that compile, and the shallow-vs-deep gotcha for each one. TS 5+ semantics.

Object Transforms

Partial<T>
Constructs a type where every property of T is set to optional. Useful for representing update payloads, patch objects, and configuration overrides where all fields may be omitted.
Required<T>
Removes optionality from every property of T, producing a type where all fields must be present. The -? mapping modifier strips the ? flag from every key.
Readonly<T>
Marks every property of T as readonly, preventing reassignment after construction. Only enforced at compile-time — the underlying object is still mutable at runtime.
Pick<T, K>
Builds a new type containing only the properties from T whose keys are in the union K. Ideal for narrowing large interfaces to the subset a function or component actually needs.
Omit<T, K>
Constructs a type by removing the properties in K from T. Unlike Pick, its K is not constrained to keyof T, so extra keys are silently ignored.
Record<K, V>
Creates an object type whose keys come from the union K and whose values all have type V. Useful for lookup tables, dictionaries, and enum-keyed maps.
Exclude<T, U>
Filters a union T by removing every member that is assignable to U. Distributes over union members via the conditional type, producing the set-difference T \ U.
Extract<T, U>
Keeps only those members of union T that are assignable to U. The dual of Exclude, giving the set-intersection T ∩ U.
NonNullable<T>
Removes null and undefined from the type T. In TS 4.9+ it is implemented as `T & {}`, which drops nullish members without altering the rest.

Function Types

String Manipulation

Conditional & Extraction

Inference Helpers

Related references