mirror of
https://github.com/type-challenges/type-challenges.git
synced 2025-12-08 19:06:13 +00:00
Tail of Array

by Anthony Fu @antfu
TypeScript 4.0 is recommended in this challenge
Implement a generic Tail<T> that takes an Array T and returns it's last element's type.
For example
type arr1 = ['a', 'b', 'c']
type arr2 = [3, 2, 1]
type tail1 = Tail<arr1> // expected to be 'c'
type tail2 = Tail<arr2> // expected to be 1