Control flow refines types: typeof, instanceof, equality checks, and user-defined type predicates (value is string).
Discriminant-free narrowing
Truthy checks narrow nullable types. in operator narrows union members with shared fields. Control-flow analysis follows return and throw too.
Self-check
- Narrow
string | numberwithtypeofin an if/else.
Editor tooling uses the same control-flow graph to autocomplete properties only valid in the current branch.
Practice: Apply type-narrowing in the playground, then explain type narrowing in one sentence without looking at notes.