Pick<T, K>
The utility type that keeps only the listed keys K of type T, like an allowlist of fields.
In more detail
Pick<UserEntity, "id" | "email"> produces { id: string; email: string }. Use it when the new shape has only a few fields.
Related terms
- Omit<T, K> — The utility type that copies type T without the listed keys K, like a denylist of fields.
- keyof — The TypeScript type operator that produces a union of an object type's property names, such as "id" | "table" | "rowCount".
- utility types — Generic types built into TypeScript, such as Partial, Pick and ReturnType, that compute a new type from an existing one.
Taught in
- Core Utilities: Partial, Required, Readonly, Pick And Omit — Production TypeScript
- Union Utilities: Exclude, Extract, NonNullable And Awaited — Production TypeScript