TypeScript Utility Types Reference: All 22 Built-in Types with Examples
TypeScript ships 22 built-in utility types that transform existing types without re-declaring them. Here is an interactive reference covering all of them — with syntax, examples, TypeScript version requirements, and cate
TypeScript ships 22 built-in utility types that transform existing types without re-declaring them. Here is an interactive reference covering all of them — with syntax, examples, TypeScript version requirements, and category filters.
Tool
TypeScript Utility Types Reference
https://devnestio.pages.dev/ts-utility-types/
Features: search by name or description, filter by category (Object / Union / Function / String / Async), copy syntax and examples in one click.
All 22 Types at a Glance
Object Utilities
| Type | What it does |
|---|---|
Partial<T> |
Makes all properties optional |
Required<T> |
Makes all properties required |
Readonly<T> |
Makes all properties readonly |
Record<K, V> |
Object type with keys K and values V |
Pick<T, K> |
Subset of T properties |
Omit<T, K> |
T without properties K |
NoInfer<T> |
Prevents inference from a position (TS 5.4+) |
Union Utilities
| Type | What it does |
|---|---|
Exclude<T, U> |
Remove U members from union T |
Extract<T, U> |
Keep only U members from union T |
NonNullable<T> |
Remove null and undefined from T |
Function Utilities
| Type | What it does |
|---|---|
ReturnType<T> |
Return type of function T |
Parameters<T> |
Parameter types of function T as tuple |
ConstructorParameters<T> |
Constructor param types as tuple |
InstanceType<T> |
Instance type of constructor T |
ThisParameterType<T> |
The this param type of function T |
OmitThisParameter<T> |
Remove this param from function T |
ThisType<T> |
Mark this context type in object literal |
Async
| Type | What it does |
|---|---|
Awaited<T> |
Recursively unwrap Promise types (TS 4.5+) |
String Utilities (TS 4.1+)
| Type | What it does |
|---|---|
Uppercase<S> |
All chars to uppercase |
Lowercase<S> |
All chars to lowercase |
Capitalize<S> |
First char to uppercase |
Uncapitalize<S> |
First char to lowercase |
Practical Examples
Partial for update payloads
interface User { id: number; name: string; email: string; }
type UserUpdate = Partial<User>;
// { id?: number; name?: string; email?: string; }
async function patchUser(id: number, changes: Partial<User>) { }
ReturnType from factory functions
function createStore() {
return { count: 0, increment() { this.count++; } };
}
type Store = ReturnType<typeof createStore>;
// { count: number; increment: () => void; }
Awaited to unwrap async types
async function fetchUser(id: number): Promise<User> { }
type FetchResult = Awaited<ReturnType<typeof fetchUser>>;
// User
NoInfer to control inference (TS 5.4+)
function createState<T>(initial: T, fallback: NoInfer<T>): T {
return initial ?? fallback;
}
createState(42, "hello"); // Error: string not assignable to number
String types for template literals
type Getter<K extends string> = `get${Capitalize<K>}`;
type GetName = Getter<"name">; // "getName"
type EnvKey<K extends string> = `VITE_${Uppercase<K>}`;
type Key = EnvKey<"apiUrl">; // "VITE_APIURL"
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.