TypeScript · Middle · Question 23 of 75
What does Extract<'a' | 'b' | 1 | 2, string> produce?
- ✓Correct answer:
'a' | 'b' - 2
1 | 2 - 3
never
Explanation
Extract<T, U> keeps the union members assignable to U - here, the string literals. The opposite Exclude would keep 1 | 2. Both utilities are distributive conditional types.