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

Narrowing is preserved inside a nested closure only under what condition?

function f(x: string | null) { if (x !== null) { const cb = () => { x.toUpperCase(); }; // ok or error? } // (compare: same code, but with `x = null;` somewhere in f) }