-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Doesn't remember the class inside a Array.map #9491
Comments
Duplicate of #9263 and #7662 and #9345 as narrowing is currently reset across function boundaries as explained in #7718 (comment). Though this keeps coming up and it seems logical that anonymous functions, this could be potentially preserved? (or at least arrow functions used as callbacks?) @mhegazy @ahejlsberg @RyanCavanaugh |
The solution here is to guard on a |
Yeah, I solved my real issue by assigning the value to a const but it seems wrong to have to that. The behaviour is the same when using interfaces with a .kind property as guard. |
I’m interested in that, is there an issue to track this solution? |
TypeScript Version: nightly (2.0.0-dev.201xxxxx)
Code
Expected behavior:
Typescript should know that
bug
is of the type SomeOtherClass inside of the map function.Actual behavior:
Property 'name' does not exist on type SomeClass | SomeOtherClass.
The text was updated successfully, but these errors were encountered: