TypeScript · Junior · Question 18 of 75
How do Pick<User, 'id' | 'name'> and Omit<User, 'password'> differ?
- ✓Correct answer:
Pickkeeps the listed properties,Omitkeeps everything except them - 2
Pickmakes properties required,Omitmakes them optional - 3They're synonyms with a different argument order
Explanation
Both create a new type from an existing one. Pick is an allowlist of keys, Omit a denylist. For example, Omit<User, 'password'> is a type for an API response without secret fields.