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

by Anthony Fu @antfu
Implement a generic First<T> that takes an Array T and returns it's first element's type.
For example
type arr1 = ['a', 'b', 'c']
type arr2 = [3, 2, 1]
type head1 = First<arr1> // expected to be 'a'
type head2 = First<arr2> // expected to be 3