RSRobince Studio

Utility Types

TypeScript ships utility types that transform existing types. Common ones are Partial, Pick, and Readonly.

  • Partial makes every property optional
  • Pick keeps only the named properties
  • Readonly blocks reassigning properties
interface User { id: number; name: string }
type Draft = Partial<User>;
type OnlyId = Pick<User, "id">;
Utility types save you from rewriting a shape by hand when you need a small variation.
Try it yourself

Loading editor…