Dmytro Morar
TypeScript

Utility types

Utility types transform existing types without duplication.

Partial<T>

type PartialUser = Partial<{ id: number; name: string }>;

Readonly<T>

type ReadonlyUser = Readonly<{ id: number; name: string }>;

Pick<T, K>

type UserPreview = Pick<{ id: number; name: string }, "id">;

Omit<T, K>

type UserWithoutId = Omit<{ id: number; name: string }, "id">;

Record<K, T>

type Permissions = Record<"admin" | "user", boolean>;

On this page