-
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
TS 4.7 Beta: Object access should be narrowable after check #48802
Comments
Isn’t that feature about computed properties, specifically? I don’t see a computed property in your example. |
In your initial example there are no computed properties - |
Thanks for the clarification! It took me a while to find the proper documentation for "computed properties". Closing issue. |
I just reread @a-tarasyuk’s PR and the logic isn’t specific to computed properties (that was just the motivation for narrowing element accesses). The reason this isn’t narrowing is that the type of the argument expression ( I agree the release notes were not clear about this, though maybe the constraints mean that this is really only particularly useful for computed properties. |
I also noticed that the predicate on the name type uses its declared type, not its flow type. I’m not sure if there was a reason we couldn’t use the flow type or if there just wasn’t a strong reason to do it. I can’t really come up with an example that looks natural. |
Hey, @andrewbranch , are you still can't come up with an example? I try to find some explanation for that behaviour. Possibly you can point me some docs? |
If I read the release blog post for v4.7 Beta correctly, the following test case should work, but it still produces an error.
Is this a bug?
TS Playground Link v4.7.0-dev.20220420
If this only works for object access with
Symbol
, it should be clarified in the blog post.FWIW, here's the example from the blog post (which works):
Originally posted by @kyliau in #45974 (comment)
The text was updated successfully, but these errors were encountered: