-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Consider contextually typing parenthesized expressions #920
Labels
Breaking Change
Would introduce errors in existing code
Bug
A bug in TypeScript
Fixed
A PR has been merged for this issue
Milestone
Comments
Should note that this would be a breaking change. Likely the breaks are bugs but still, we'll have |
This was discussed in passing at the design meeting today and it seemed like there was broad agreement that we should do it. |
We now perform the appropriate contextual typing. |
# for free
to subscribe to this conversation on GitHub.
Already have an account?
#.
Labels
Breaking Change
Would introduce errors in existing code
Bug
A bug in TypeScript
Fixed
A PR has been merged for this issue
We've seen some issues where expressions which are non-obviously parenthesized lose contextual typing and cause issues:
This trips people up because they don't expect parentheses to change the type system, especially when parens are required to make an expression parse.
With the improvements in the type system with union types, we may have crossed the line where we can more aggressively apply contextual types. The 'new' workaround in cases (if there are any) where a contextual type needs to be avoided would be to use a type assertion to
any
or some other type which lacks a contextual impact.The text was updated successfully, but these errors were encountered: