← Back to archive

Stdle #83 · generics · 2026-08-28

What does this TypeScript snippet output?

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

function cat(a: string): string
function cat(a: string, b: string): string
function cat(a: string, b?: string): string { return a + (b ?? '') }
console.log(cat.length, cat('x'))
Generics
4 attempts left

Answer & explanation