Zest.

TypeScript: Utility types

A short, tested TypeScript example for utility types. Copy it and adjust the names and paths for your project.

TypeScript
type User = { id: number; name: string; email: string };

type Draft = Partial<User>;                 // all optional
type Preview = Pick<User, "id" | "name">;   // only these
type Public = Omit<User, "email">;          // all but this
type Scores = Record<string, number>;       // { [k: string]: number }
type Frozen = Readonly<User>;               // no reassignment

Find it in Zest

Search for “typescript utility types” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More TypeScript examples

All TypeScript examples