Back

Utility Types (Partial, Omit, Record)

Utility types are built-in TypeScript helpers that transform existing types. They save you from rewriting types by hand.

interface User {
  name: string
  age: number
  email: string
  role: string
}

// Partial: makes all properties optional
type PartialUser = Partial<User>

// Omit: removes specific properties
type PublicUser = Omit<User, "email" | "role">

// Pick: keeps only specific properties
type UserPreview = Pick<User, "name" | "age">

// Record: creates an object type with specific keys
type UserMap = Record<string, User>

Roadmap