TypeScript · Middle · Question 9 of 75
How does Exclude<T, U> differ from Omit<T, K>?
- ✓Correct answer:
Excluderemoves members from a union,Omitremoves properties from an object type - 2
Excluderemoves properties from an object,Omitremoves union members - 3They're synonyms with a different order of type parameters
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.