← Back to archive

Stdle #97 · generics · 2026-09-11

What does this TypeScript snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

function first<T extends unknown[]>(a: T) { return a[0] }
console.log(first<number[]>([10, 20]))
Generics
4 attempts left

Answer & explanation