TypeScriptTypeScript11 min read

TypeScript Utility Types: Built-in Type Helpers

Master TypeScript utility types - Partial, Required, Pick, Omit, and more. These built-in type helpers make working with types much easier. Essential knowledge for TypeScript developers.

Rachel Kim
December 18, 2025
0.0k0

TypeScript comes with powerful utility types that transform existing types. Instead of writing complex type definitions from scratch, you can use these built-in helpers. They save time and make your code cleaner.

What are Utility Types?

Utility types are built-in TypeScript types that transform other types. They take a type and return a new type with modifications. Think of them as functions for types.

Most Useful Ones

Partial makes all properties optional, Required makes them all required, Pick selects specific properties, Omit removes properties, and Record creates object types. These cover most of what you need.

Real-World Usage

I'll show you practical examples - making API request types optional, selecting specific properties, creating mapped types. These patterns you'll use constantly in TypeScript projects.

Combining Utility Types

The real power comes from combining utility types. You can chain them together to create exactly the type you need. This is how professionals work with types.

#TypeScript#Utility Types#Partial#Pick#Omit

Common Questions & Answers

Q1

What are TypeScript utility types?

A

Utility types are built-in TypeScript types that transform existing types. Common ones: Partial (makes all properties optional), Required (makes all required), Pick (selects properties), Omit (removes properties), Record (creates object type), Readonly (makes properties readonly). They help create new types from existing ones.

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

// Partial - all properties optional
type PartialUser = Partial<User>;
// { id?: number; name?: string; email?: string; age?: number; }

// Required - all properties required (even if originally optional)
type RequiredUser = Required<PartialUser>;

// Pick - select specific properties
type UserPreview = Pick<User, 'id' | 'name'>;
// { id: number; name: string; }

// Omit - remove specific properties
type UserWithoutId = Omit<User, 'id'>;
// { name: string; email: string; age: number; }

// Readonly - make all properties readonly
type ReadonlyUser = Readonly<User>;
Q2

How do I use Record and other utility types?

A

Record creates an object type with specified keys and value types. Useful for dictionaries and mapped objects. Combine utility types to create complex types. Use them for API responses, form data, and type transformations.

typescript
// Record - create object type
type UserRoles = Record<string, 'admin' | 'user' | 'guest'>;
const roles: UserRoles = {
  alice: 'admin',
  bob: 'user'
};

// Combining utility types
interface Product {
  id: number;
  name: string;
  price: number;
  description?: string;
}

// Create update type (all optional except id)
type ProductUpdate = Partial<Omit<Product, 'id'>> & { id: number };

// Create API response type
type ApiResponse<T> = {
  data: T;
  status: number;
  message: string;
};

type ProductResponse = ApiResponse<Product>;