TypeScript Utility Types
Pick<T, K> — select named properties
Pick builds a type from specified existing keys of T, retaining their value types and property modifiers. A selected key must belong to keyof T. This is useful for narrowing a public contract, but it neither clones an object nor deletes any runtime properties. For unions, consider whether keys are common to every member before using Pick. Example output: "3 Pen 3". Verified with strict TypeScript 5.8.3, ES2022 and Node.js 22.16.0. This utility affects static typing; no runtime validation or transformation is supplied by the type itself.
Formal Syntax & Structure
typescript syntaxtypescript
Pick<T, K>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| T | type parameter | Source object type. |
| K | K extends keyof T | Keys selected from the source type. |
Working Example
Example Snippettypescript
type Item = { id: number; name: string; internal: boolean };const item: Item = { id: 3, name: "Pen", internal: true };const summary: Pick<Item, "id" | "name"> = item;console.log(summary.id, summary.name, Object.keys(summary).length);