TypeScript · Senior · Question 52 of 75
What does tail-recursion elimination for conditional types (TS 4.5) allow?
- ✓Correct answer: Recursive conditional types in tail position can recurse much deeper (about 1000 levels) without "excessively deep" errors
- 2Unlimited recursion in all types
- 3Recursion in runtime functions
Explanation
Write recursive types with an accumulator so the recursive call is the whole branch result, e.g. Trim<Rest, [...Acc, X]>.