TypeScript utility types

Utility types like Partial, Pick, and Omit appear in nearly every TypeScript project. AI generates these for API wrappers and form handlers.

typescriptutility typesOmitPickPartial
typescript
interface User {
  id: number
  name: string
  email: string
  password: string
  createdAt: Date
}

type PublicUser = Omit<User, 'password'>
type UserPreview = Pick<User, 'id' | 'name'>
type UpdateUser = Partial<Omit<User, 'id' | 'createdAt'>>

function updateUser(id: number, changes: UpdateUser): void {
  console.log(id, changes)
}

updateUser(1, { name: 'Alice' })
updateUser(1, { email: 'a@b.com', password: 'new' })

Question

What fields are available on PublicUser, UserPreview, and UpdateUser? Why would you use UpdateUser for the changes parameter instead of Partial<User>?