Utility Pick
Question
What does Pick<T, K> do?
Hint
Pick<T, "a" | "b"> keeps only a and b from T.
Explanation
Pick<T, K> creates a new type by selecting only the properties listed in K (which must be keys of T). type User = { name: string; age: number; email: string }. type BasicUser = Pick<User, "name" | "email"> results in { name: string; email: string }. Useful for creating views, DTOs, or API responses with a subset of fields. Implemented as type Pick<T, K extends keyof T> = { [P in K]: T[P]; }.
Related Resources
Related Lessons
- Utility Types
Learn utility types.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.