TypeScript · Senior · Question 3 of 75
What is ToArray<string | number> if type ToArray<T> = T extends any ? T[] : never?
- ✓Correct answer:
string[] | number[] - 2
(string | number)[] - 3
never
Explanation
A conditional type over a "naked" type parameter distributes over a union: the condition is applied to each member separately. This is a distributive conditional type - Exclude and Extract are built on it.