A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-46.ts
1typeCat={type:"cat";meow:()=>string}
2functionisCat(a:{type:string}):aisCat{
3returna.type==="cat"
4}
5console.log(isCat({type:"dog"}))
Narrowing
Answer & explanation
Console output
false
Why
This type predicate narrows to `Cat` only when its body returns true, and the body compares `a.type === "cat"`. The argument has `type` "dog", so the function returns false and no narrowing to `Cat` would occur. The compile-time `a is Cat` claim is honoured only by what the runtime boolean reports.