Menu

TypeScript Utility Types: The Complete List with Examples

Every built-in TypeScript utility type in one place: Partial, Required, Readonly, Pick, Omit, Record, Exclude, Extract, NonNullable, Parameters, ReturnType, Awaited, the string types and more, each with a one-line description and a runnable example.

This page includes runnable editors - edit, run, and see output instantly.

Utility types are generic types built into TypeScript that turn one type into another. Instead of writing a second User type with every field optional, you write Partial<User>; instead of copying three fields, Pick<User, "id" | "name">. They are global, so no import is needed.

When User changes, all four derived types follow. TypeScript's standard library (lib.es5.d.ts) declares 22 utility types. The sections below list all of them, grouped by the kind of type they work on, with a link to the detailed page where there is one.

Object Types: Partial, Required, Readonly, Pick, Omit, Record

Utility typeWhat it doesExample
Partial<T>makes every property optionalPartial<User> for an update payload
Required<T>makes every property required (removes ?)Required<Config> after defaults are applied
Readonly<T>makes every property readonlyReadonly<State>
Pick<T, K>keeps only the keys KPick<User, "id" | "name">
Omit<T, K>removes the keys KOmit<User, "password">
Record<K, V>an object type with keys K and values VRecord<"en" | "de", string>

Required<T> is the opposite of Partial<T>; the Partial page covers both, including the explicit undefined that a spread like this one lets through.

Union Types: Exclude, Extract, NonNullable

Utility typeWhat it doesExample
Exclude<U, M>removes union members assignable to MExclude<"a" | "b" | "c", "a"> is "b" | "c"
Extract<U, M>keeps union members assignable to MExtract<string | number, number> is number
NonNullable<T>removes null and undefinedNonNullable<string | null> is string

These three operate on unions, not objects. That is the key difference from Pick and Omit, which take an object type and a list of its keys.

Function and Class Types: Parameters, ReturnType and More

Utility typeWhat it doesExample
ReturnType<F>the return type of a function typeReturnType<typeof createStore>
Parameters<F>the parameter types as a tupleParameters<typeof fetchPage>[0]
ConstructorParameters<C>a class constructor's parameters as a tupleConstructorParameters<typeof Point>
InstanceType<C>the instance type a constructor createsInstanceType<typeof Point>
ThisParameterType<F>the type of a function's this parameterThisParameterType<typeof greet>
OmitThisParameter<F>the function type without its this parameterthe type of greet.bind(obj)
ThisType<T>sets the type of this inside an object literal's methodsused with noImplicitThis in builder APIs
NoInfer<T>stops a type parameter from being inferred from this positionfallback: NoInfer<C>

typeof createOrder is needed because these utilities take a type, and createOrder is a value. The same goes for classes: typeof Point is the constructor type, while plain Point as a type already means the instance type.

NoInfer controls where a generic gets its type from:

Without NoInfer, TypeScript would infer C from both arguments and widen it to "red" | "green" | "blue", so the typo in the fallback would be accepted.

String Types: Uppercase, Lowercase, Capitalize, Uncapitalize

Utility typeWhat it doesExample
Uppercase<S>uppercases a string literal typeUppercase<"get"> is "GET"
Lowercase<S>lowercases itLowercase<"GET"> is "get"
Capitalize<S>uppercases the first characterCapitalize<"name"> is "Name"
Uncapitalize<S>lowercases the first characterUncapitalize<"Name"> is "name"

These four are built into the compiler rather than written in TypeScript, and they are most useful inside template literal types, such as `on${Capitalize<E>}` for event handler names.

Promises: Awaited

Utility typeWhat it doesExample
Awaited<T>the type you get from await, unwrapping nested promisesAwaited<Promise<Promise<number>>> is number

Awaited<ReturnType<typeof fn>> is the standard way to name the result type of an async function without declaring it separately.

Combining Utility Types

Utility types nest. A few combinations come up often enough to be worth knowing by heart:

Read a nested utility type from the inside out: Readonly<Pick<Post, "id" | "title">> first keeps two properties, then makes them read-only. The same parts build a PartialBy helper that makes only some keys optional; the Partial page writes it out.

Utility Types Do Nothing at Runtime

Every utility type is erased when the code compiles. A value typed Omit<User, "password"> can still carry a password at runtime if the object it came from had one:

The type only limits what your code is allowed to read. To remove a field from the data, destructure it away as in the last lines, and to stop mutation at runtime use Object.freeze, not Readonly. The built-in types are one-line mapped types and conditional types, so the same tools let you write your own.

Frequently Asked Questions

What are utility types in TypeScript?

Generic types that ship with TypeScript and transform other types: Partial<T> makes every property optional, Pick<T, K> keeps some properties, ReturnType<F> gets a function's return type, and so on. They are declared in the standard library, so you use them without importing anything.

Do I need to import utility types?

No. Partial, Omit, Record, ReturnType and the rest are global types from TypeScript's built-in library files. Write Partial<User> anywhere; no import and no npm package is needed.

Which utility types are built into TypeScript?

22, all declared in lib.es5.d.ts: Partial, Required, Readonly, Pick, Omit, Record, Exclude, Extract, NonNullable, Parameters, ConstructorParameters, ReturnType, InstanceType, ThisParameterType, OmitThisParameter, ThisType, NoInfer, Awaited, Uppercase, Lowercase, Capitalize and Uncapitalize.

Do utility types change objects at runtime?

No. They only describe types and are erased from the JavaScript output. Omit<User, "password"> does not delete a password property, and Readonly<T> does not freeze anything. To change the actual object, write the code: a destructuring rest pattern, Object.freeze, and so on.

Can I write my own utility types?

Yes. The built-in ones are ordinary TypeScript: most are one-line mapped types or conditional types in lib.es5.d.ts. type Nullable<T> = { [K in keyof T]: T[K] | null } is a custom utility type written the same way.

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED