Local variable refinements are unsafe in TS and Flow. Both are bad, TS is the worst. Seems obvious in hindsight but neither handle local refinement invalidation correctly. I'm not speaking abstractly, this has caused bugs in my code before.
-
-
Anyway, variable refinement is an action performed by the typechecker that removes impossible subtypes from the known type of the variable based on control flow or typehints. let a: string | number = 5; if (typeof a === 'string') { // `a` must be a string return a.length; }
-
Is "refinement" different from "narrowing"?
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
he/him 