← Back to archive

Stdle #79 · narrowing · 2026-08-24

What does this TypeScript snippet output?

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

type A = { kind: "a"; x: number }
type B = { kind: "b"; y: number }
function f(v: A | B) { return "x" in v }
console.log(f({ kind: "b", y: 2 }))
Narrowing
4 attempts left

Answer & explanation