TypeScript · Junior · Question 18 of 75

How do Pick<User, 'id' | 'name'> and Omit<User, 'password'> differ?

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.

Further reading

Problem with a question

TypeScript · Junior · question 18

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz