TypeScript · Middle · Question 9 of 75

How does Exclude<T, U> differ from Omit<T, K>?

Explanation

Exclude<'a' | 'b' | 'c', 'a'> → 'b' | 'c'. Omit<User, 'password'> → an object without the field. Paired utilities: Extract (keep matching union members) and Pick (keep properties). NonNullable<T> removes null and undefined.

Further reading

Problem with a question

TypeScript · Middle · question 9

Test yourself

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

Take this quiz