11 March 2025

TypeScript Utility Types

Partial, Required, Pick, Omit—these utility types save hours of boilerplate. Did you know you can also create your own conditional types?

TypeScript utility types are incredible time savers.

My most used:

  • Partial<T> — Make all properties optional
  • Required<T> — Make all properties required
  • Pick<T, K> — Pick specific properties
  • Omit<T, K> — Omit specific properties
  • Record<K, T> — Create an object type with specific keys

Example:

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

// Use all properties except password
type UserRegistration = Omit<User, 'password'>;

// Use only name and email
type UserContact = Pick<User, 'name' | 'email'>;

Custom conditional types unlock even more power:

type Nullable<T> = T | null;
type Async<T> = Promise<T>;

The TypeScript handbook has great docs on utility types.