← Back to archive

Stdle #46 · narrowing · 2026-07-22

What does this TypeScript snippet output?

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

type Cat = { type: "cat"; meow: () => string }
function isCat(a: { type: string }): a is Cat {
return a.type === "cat"
}
console.log(isCat({ type: "dog" }))
Narrowing
4 attempts left

Answer & explanation