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
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: