What is the Pick utility type?
Why Interviewers Ask This
This tests whether you can apply TypeScript knowledge to real-world scenarios. Interviewers are looking for clarity of thought and evidence that you've encountered this in production code.
Answer
Pick<T, K> creates a new type by selecting only the properties K from type T. K must be a key (or union of keys) of T. Implementation: type Pick<T, K extends keyof T> = { [P in K]: T[P] }. Example: interface User { id: number; name: string; email: string; password: string; } type PublicUser = Pick<User, "id" | "name" | "email">; — PublicUser has only these three properties, excluding password. Useful for: API response shapes (pick only safe-to-expose fields), form data types (pick only editable fields), derived types that need a subset of a larger type. Compare with Omit: Pick keeps the specified keys; Omit removes the specified keys. Use Pick when the subset is small and explicit; use Omit when excluding a small number of properties from a large type. Both create new types without mutating the original.
Common Mistake
Rushing to answer is a common mistake. Take two seconds to structure your response: definition → example → trade-off. This structure makes complex TypeScript answers easy to follow.