PureDevTools

TypeScript Utility Types Reference

Complete interactive reference for all 21 built-in TypeScript utility types — search, filter, copy examples, and try live transformations

All processing happens in your browser. No data is sent to any server.

Try It

Select a utility type, enter a type definition, and see the transformation applied.

Constructs a type with all properties of T set to optional. Useful for update/patch operations where you only need to supply some fields.

Result
{
  name?: string;
  age?: number;
  email?: string;
}

All properties set to optional

Filter by category

Showing 21 of 21 utility types

Object Types

6 types

Partial

Object Types
Partial<T>

Constructs a type with all properties of T set to optional. Useful for update/patch operations where you only need to supply some fields.

Before
interface User {
  id: number;
  name: string;
  email: string;
}
After
// Partial<User>
interface PartialUser {
  id?: number;
  name?: string;
  email?: string;
}

Required

Object Types
Required<T>

Constructs a type with all properties of T set to required. The opposite of Partial<T> — removes all optional modifiers.

Before
interface Config {
  host?: string;
  port?: number;
  debug?: boolean;
}
After
// Required<Config>
interface ResolvedConfig {
  host: string;
  port: number;
  debug: boolean;
}

Readonly

Object Types
Readonly<T>

Constructs a type with all properties of T set to readonly. Prevents reassignment after initialization. Note: only one level deep — nested objects are not made readonly.

Before
interface Point {
  x: number;
  y: number;
}
After
// Readonly<Point>
interface ImmutablePoint {
  readonly x: number;
  readonly y: number;
}

Record

Object Types
Record<Keys, Type>

Constructs an object type whose property keys are Keys and values are Type. Ideal for dictionaries and maps with a fixed set of keys.

Before
type Role = "admin" | "editor" | "viewer";
type Permission = "read" | "write" | "delete";
After
// Record<Role, Permission[]>
const rolePermissions: Record<Role, Permission[]> = {
  admin: ["read", "write", "delete"],
  editor: ["read", "write"],
  viewer: ["read"],
};

Pick

Object Types
Pick<Type, Keys>

Constructs a type by picking a set of properties Keys from Type. Creates a subset type from an existing interface.

Before
interface User {
  id: number;
  name: string;
  email: string;
  password: string;
  createdAt: Date;
}
After
// Pick<User, "id" | "name" | "email">
type PublicUser = {
  id: number;
  name: string;
  email: string;
};

Omit

Object Types
Omit<Type, Keys>

Constructs a type by picking all properties from Type and then removing Keys. The inverse of Pick — exclude specific properties instead of selecting them.

Before
interface User {
  id: number;
  name: string;
  email: string;
  password: string;
}
After
// Omit<User, "password">
type SafeUser = {
  id: number;
  name: string;
  email: string;
};

Union & Conditional Types

3 types

Exclude

Union & Conditional Types
Exclude<UnionType, ExcludedMembers>

Constructs a type by excluding from UnionType all union members that are assignable to ExcludedMembers. Operates on union types, not object property keys.

Before
type Status = "pending" | "active" | "inactive" | "deleted";
After
// Exclude<Status, "deleted">
type ActiveStatus = "pending" | "active" | "inactive";

Extract

Union & Conditional Types
Extract<Type, Union>

Constructs a type by extracting from Type all union members that are assignable to Union. The opposite of Exclude — keeps only the matching members.

Before
type Shape = "circle" | "square" | "triangle" | "hexagon";
type PolygonShape = "square" | "triangle" | "hexagon" | "pentagon";
After
// Extract<Shape, PolygonShape>
type Polygon = "square" | "triangle" | "hexagon";

NonNullable

Union & Conditional Types
NonNullable<Type>

Constructs a type by excluding null and undefined from Type. Ensures a value is not nullish after a null check guard.

Before
type MaybeString = string | null | undefined;
After
// NonNullable<MaybeString>
type DefiniteString = string;

Function Types

7 types

Parameters

Function Types
Parameters<Type>

Constructs a tuple type from the parameter types of function type Type. Useful for capturing and forwarding arguments without repeating the signature.

Before
function createUser(
  name: string,
  age: number,
  admin: boolean
): void {}
After
// Parameters<typeof createUser>
type CreateUserArgs = [name: string, age: number, admin: boolean];

// Usage:
const args: Parameters<typeof createUser> = ["Alice", 30, true];
createUser(...args);

ConstructorParameters

Function Types
ConstructorParameters<Type>

Constructs a tuple type from the parameter types of a constructor function type. Like Parameters but for class constructors accessed via typeof ClassName.

Before
class EventEmitter {
  constructor(maxListeners: number, name: string) {}
}
After
// ConstructorParameters<typeof EventEmitter>
type EmitterArgs = [maxListeners: number, name: string];

function createEmitter(
  ...args: ConstructorParameters<typeof EventEmitter>
) {
  return new EventEmitter(...args);
}

ReturnType

Function Types
ReturnType<Type>

Constructs a type from the return type of function type Type. Useful for inferring complex return types without duplicating type declarations.

Before
function getUser() {
  return { id: 1, name: "Alice", email: "alice@example.com" };
}
After
// ReturnType<typeof getUser>
type User = {
  id: number;
  name: string;
  email: string;
};

InstanceType

Function Types
InstanceType<Type>

Constructs a type consisting of the instance type of a constructor function type. Useful when you only have the class constructor reference via typeof.

Before
class Http {
  get(url: string): Promise<Response> { return fetch(url); }
  post(url: string, body: unknown): Promise<Response> {
    return fetch(url, { method: "POST", body: JSON.stringify(body) });
  }
}
After
// InstanceType<typeof Http>
type HttpInstance = Http; // equivalent to the class instance type

function useHttp(client: InstanceType<typeof Http>) {
  return client.get("/api/users");
}

ThisParameterType

Function Types
ThisParameterType<Type>

Extracts the type of the this parameter from a function type. Returns unknown if the function type has no explicit this parameter.

Before
function greet(
  this: { name: string },
  greeting: string
): string {
  return `${greeting}, ${this.name}!`;
}
After
// ThisParameterType<typeof greet>
type GreetThis = { name: string };

const obj: ThisParameterType<typeof greet> = { name: "Alice" };
greet.call(obj, "Hello"); // "Hello, Alice!"

OmitThisParameter

Function Types
OmitThisParameter<Type>

Removes the this parameter from Type. If the function type has no this parameter, returns Type unchanged. Useful when binding a function to a specific this context.

Before
function toHex(this: Number): string {
  return this.toString(16);
}
After
// OmitThisParameter<typeof toHex>
type BoundToHex = () => string;

const hex: OmitThisParameter<typeof toHex> = toHex.bind(255);
console.log(hex()); // "ff"

ThisType

Function Types
ThisType<Type>

Acts as a marker for contextual this types in object literals. Does not transform the type — it annotates the this type for methods. Requires noImplicitThis in tsconfig.

Before
interface ComponentMethods {
  data(): { count: number };
  increment(): void;
}
After
// ThisType<T> annotates 'this' inside the object literal
const component: ComponentMethods & ThisType<{ count: number }> = {
  data() { return { count: 0 }; },
  increment() {
    this.count++; // this: { count: number }
  },
};

String Types

4 types

Uppercase

String Types
Uppercase<StringType>

Converts each character of a string literal type to uppercase. Operates at the type level on string literal types and template literal types.

Before
type Direction = "north" | "south" | "east" | "west";
After
// Uppercase<Direction>
type UpperDirection = "NORTH" | "SOUTH" | "EAST" | "WEST";

Lowercase

String Types
Lowercase<StringType>

Converts each character of a string literal type to lowercase. Operates at the type level on string literal types.

Before
type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
After
// Lowercase<HTTPMethod>
type LowerMethod = "get" | "post" | "put" | "delete" | "patch";

Capitalize

String Types
Capitalize<StringType>

Converts the first character of a string literal type to uppercase. Leaves remaining characters unchanged.

Before
type EventName = "click" | "focus" | "blur" | "change";
After
// `on${Capitalize<EventName>}`
type Handler = "onClick" | "onFocus" | "onBlur" | "onChange";

Uncapitalize

String Types
Uncapitalize<StringType>

Converts the first character of a string literal type to lowercase. The opposite of Capitalize. Leaves remaining characters unchanged.

Before
type ComponentName = "Button" | "Input" | "Modal" | "Dropdown";
After
// Uncapitalize<ComponentName>
type InstanceKey = "button" | "input" | "modal" | "dropdown";

Promise Types

1 type

Awaited

Promise Types
Awaited<Type>

Recursively unwraps the type returned by a Promise. Models the await operator — handles nested Promise<Promise<T>> chains. Added in TypeScript 4.5.

Before
async function fetchUser(): Promise<{ id: number; name: string }> {
  const res = await fetch("/api/user");
  return res.json();
}
After
// Awaited<ReturnType<typeof fetchUser>>
type User = { id: number; name: string };

// Also handles nested promises:
// Awaited<Promise<Promise<string>>> = string

You need to make all fields of your User interface optional for a PATCH endpoint, but you can never remember: is it Partial<User> or Optional<User>? And for the response that excludes the password field — is it Omit<User, "password"> or Pick<User, Exclude<keyof User, "password">>? TypeScript has 21 built-in utility types and the docs don’t show them all on one page.

Why This Reference (Not the TypeScript Playground)

PureDevTools has a TypeScript Playground for experimenting with type definitions. This reference covers all 21 TypeScript built-in utility typesPartial, Required, Readonly, Record, Pick, Omit, Exclude, Extract, NonNullable, Parameters, ReturnType, Awaited, and more — with live examples, syntax, use cases, and a try-it playground for each type.

What Are TypeScript Utility Types?

TypeScript utility types are built-in generic types that transform or derive new types from existing ones. They are part of the TypeScript standard library — no imports required. Every utility type takes one or more type parameters and returns a transformed type at compile time.

Utility types let you express common type transformations concisely:

TypeScript ships 21 built-in utility types, grouped into five categories: Object Types, Union & Conditional Types, Function Types, String Types, and Promise Types.

Object Utility Types

Object utility types transform object/interface types by modifying their properties.

Partial<T>

Makes every property of T optional. The resulting type requires no properties, but still validates that any provided values match their declared types.

interface User {
  id: number;
  name: string;
  email: string;
}

function updateUser(id: number, changes: Partial<User>): User {
  // changes may have any combination of {id, name, email}
}

updateUser(1, { name: "Alice" });          // ✓
updateUser(1, { email: "a@example.com" }); // ✓
updateUser(1, { name: "Alice", email: "a@example.com" }); // ✓

When to use: HTTP PATCH requests, React setState, form partial updates, merging default values.

Required<T>

The opposite of Partial<T>. Removes all ? optional markers, making every property required.

interface Config {
  host?: string;
  port?: number;
  timeout?: number;
}

function connect(config: Required<Config>) {
  // All three fields guaranteed present
}

When to use: After applying defaults, after validation, when passing a fully-resolved config.

Readonly<T>

Adds readonly to every property. TypeScript will error if any code attempts to reassign a property after initialization.

Note: Readonly<T> is shallow — nested objects remain mutable. Use DeepReadonly patterns or as const for deep immutability.

function processPoint(point: Readonly<Point>) {
  point.x = 10; // Error: Cannot assign to 'x' because it is a read-only property.
}

When to use: Immutable state in Redux, frozen config objects, pure function parameters.

Record<Keys, Type>

Creates an object type mapping every member of the Keys union to Type. Equivalent to { [K in Keys]: Type }.

type Color = "red" | "green" | "blue";

const hex: Record<Color, string> = {
  red: "#ff0000",
  green: "#00ff00",
  blue: "#0000ff",
};

When to use: Lookup tables, dictionaries, exhaustive mappings of enum-like unions.

Pick<Type, Keys>

Selects a subset of properties from Type. Only the listed keys are included in the result.

type UserSummary = Pick<User, "id" | "name">;
// { id: number; name: string }

When to use: API response shapes, component props from a larger model, safe public-facing types.

Omit<Type, Keys>

The inverse of Pick — includes all properties except the listed keys.

type CreateUserInput = Omit<User, "id" | "createdAt">;
// All User fields except id and createdAt

When to use: Removing auto-generated fields for creation payloads, removing sensitive fields before sending to client.

Union & Conditional Utility Types

These operate on union types rather than object types.

Exclude<UnionType, ExcludedMembers>

Removes union members that are assignable to ExcludedMembers.

type NonNullString = Exclude<string | null | undefined, null | undefined>;
// string

Extract<Type, Union>

Keeps only union members that are assignable to Union. The intersection of two union types.

type CommonStatus = Extract<"draft" | "published", "published" | "archived">;
// "published"

NonNullable<Type>

Shorthand for Exclude<T, null | undefined>. Ensures a type is not nullish.

type SafeId = NonNullable<number | null | undefined>;
// number

When to use: After null checks, in filter callbacks (array.filter(Boolean)), asserting values are present.

Function Utility Types

Extract type information from function signatures.

Parameters<Type>

Produces a tuple of the parameter types of a function.

type CreateArgs = Parameters<typeof createUser>;
// [name: string, age: number, admin: boolean]

ConstructorParameters<Type>

Like Parameters but for class constructors, accessed via typeof ClassName.

type DbArgs = ConstructorParameters<typeof Database>;
// [url: string, options?: DbOptions]

ReturnType<Type>

Extracts the return type from a function type.

type UserResult = ReturnType<typeof getUser>;
// { id: number; name: string; email: string }

Tip: Combine with Awaited for async functions: Awaited<ReturnType<typeof fetchUser>>.

InstanceType<Type>

Gets the instance type of a class constructor. Equivalent to writing the class name as a type, but works with generic constructor references.

ThisParameterType<Type>

Extracts the type of the this parameter from a function that declares one explicitly.

OmitThisParameter<Type>

Removes the this parameter from a function type. Reflects what .bind() does at runtime.

ThisType<Type>

A marker type — does not transform anything. It annotates the contextual this type for methods in object literals. Requires noImplicitThis: true in tsconfig.

String Utility Types

These operate on string literal types and template literal types.

Uppercase<StringType>

Converts string literals to uppercase at the type level.

type Shout = Uppercase<"hello" | "world">;
// "HELLO" | "WORLD"

Lowercase<StringType>

Converts string literals to lowercase at the type level.

Capitalize<StringType>

Capitalizes the first character of each string literal.

type HandlerName = `on${Capitalize<"click" | "focus">}`;
// "onClick" | "onFocus"

Uncapitalize<StringType>

Lowercases the first character. Inverse of Capitalize.

Promise Utility Types

Awaited<Type>

Recursively unwraps Promise<T> — works for nested promise chains too. Added in TypeScript 4.5.

type Result = Awaited<Promise<Promise<string>>>;
// string

// Combining with ReturnType:
type FetchedUser = Awaited<ReturnType<typeof fetchUser>>;

When to use: Typing Promise.all() results, extracting resolved value types from async functions.

Frequently Asked Questions

Do utility types affect runtime performance?

No. Utility types are erased at compile time and produce no JavaScript output. They are purely a compile-time type-checking mechanism.

Can I chain multiple utility types?

Yes. For example: Readonly<Partial<User>> makes all User properties optional and readonly. Awaited<ReturnType<typeof fetchUser>> extracts the resolved type of an async function. You can compose them freely.

What is the difference between Omit and Exclude?

Omit<T, Keys> works on object types and removes named properties. Exclude<T, U> works on union types and removes union members. They are not interchangeable. Omit<User, "password"> removes the password property from an interface; Exclude<"a" | "b" | "c", "b"> removes "b" from a union.

When should I use Pick vs. explicit interface?

Use Pick<T, K> when you want to select a subset of an existing interface and stay in sync with it automatically. If User adds a new property, Pick<User, "id" | "name"> is unaffected. An explicit { id: number; name: string } interface would diverge silently.

What TypeScript version introduced Awaited?

Awaited<T> was added in TypeScript 4.5 (released November 2021). The string utility types (Uppercase, Lowercase, Capitalize, Uncapitalize) were added in TypeScript 4.1. All other utility types have been available since TypeScript 2.1 or earlier.

Can I create my own utility types?

Yes. Any generic type using mapped types, conditional types, infer, or template literal types is a custom utility type. Examples: DeepPartial<T>, Mutable<T> (remove readonly), Flatten<T[]>. Utility types from the ts-toolbelt and type-fest libraries extend the built-in set significantly.

Related Tools

More JavaScript Tools