-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type narrowing context is lost within closures #46118
Comments
And another duplicate of #9998. |
Yeah, that issue looks like a master issue collecting all control flow analysis issues :) |
The exact same issue you describe comes up again and again and again. I probably have seen at least 50 issues already. It's all due to the difficulties described in #9998. |
More specifically, control flow analysis issues across function boundaries. Which is not an easy problem to solve. |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
π Search Terms
typescript union typed narrowing lost in closures
type narrowing closures
π Version & Regression Information
Typescript versions 4.4.3 and still exists on Nightly 4.5.0-dev
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Type narrowing is working as expected when following control flow, however when the variable is used inside a closures scope (arrow functions or normal functions) it reverts back to it's declared type losing all narrowing inferred from the containing scope.
π Expected behavior
Type narrowing should continue to work inside the context of closures.
The text was updated successfully, but these errors were encountered: