Advanced
Build First, Last and Concat
Write three generic types: First<T extends unknown[]>, Last<T extends unknown[]> and Concat<A extends unknown[], B extends unknown[]>.
First<[1, 2, 3]> is 1, Last<[1, 2, 3]> is 3, Concat<[1], [2, 3]> is [1, 2, 3]. For an empty tuple, First and Last are never.
What Check tests
- Your code has no type errors
- First picks the first element
- First is not the second element
- Last picks the last element
- Last of an empty tuple is never
- Concat joins in order
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.