A possibly more elegant TypeScript solution:
type NonEmpty<T> = [T, ...T[]];
function head<T>(input: NonEmpty<T>): T {
return input[0];
}
https://www.typescriptlang.org/play/?ssl=5&ssc=2&pln=1&pc=1#...