← Back to archive

Stdle #15 · generics · 2026-06-21

What does this TypeScript snippet output?

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

function g<T = string>(x = 5): number { return x }
console.log(g())
Generics
4 attempts left

Answer & explanation