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

Why does the second `x.toUpperCase()` fail even though `x` was clearly a string at the closure's definition?

function g(x: string | number) { const cb = () => { x.toUpperCase(); }; if (typeof x === "string") { cb(); } }