Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardTypeScriptcontrol-flow analysis pitfallsSingle-choice MCQ

Control-flow analysis narrows `x` inside the closure incorrectly here from a runtime perspective. What type does TypeScript assign to `x` at the marked line, and why is that a known soundness gap?

function f(x: string | null) { if (x !== null) { setTimeout(() => { x; // <-- type here }); } }