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.
-
-
Where are you seeing flow break down with invalidation? Pretty sure it handles that TS example fine.
-
It does handle the TS case. My Flow tweet above has an example that does not fail when indirection is involved though.
End of conversation
New conversation -
-
-
Did you use any hack or anything to work around this?
-
Nope. I just live with it. There's a bunch of things to be aware of, which is what motivates my tweets so others can be aware too.
- 1 more reply
New conversation -
-
-
To be completely honest, these are not _local_ variables, these are _closed-over_ variables.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Yeah, this is a known limitation unfortunately. There is a discussion here https://github.com/microsoft/TypeScript/issues/9998 …. Some inlining might help catch some more errors but there are limits to how deep it would be practical to do that.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Ouch, I didn't know this. Thanks for including a clear example!
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
lol cool. Closure is, I think it's fair to say, a bit *overly* cautious in similar situations, and of course people always used to get mad about that too.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Looks like an outright bug. I can't find an open issue for it, though, have you reported it? This one is similar, but probably not the same:https://github.com/microsoft/TypeScript/issues/15835 …
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
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 