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

In `g`, the second `b.v.toUpperCase()` after `mutate()` compiles fine. What assumption in TypeScript's control-flow analysis makes this possible (and potentially unsound)?

type Box = { v: string | null }; function g(b: Box) { if (b.v !== null) { b.v.toUpperCase(); mutate(); b.v.toUpperCase(); } } function mutate() {}