Adjust incompatible-with-await to be more strict on intersections #3598
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PR #3560 introduced the notion of a type which is 'incompatible with await' and used that to introduce an error on
await e
when the static type ofe
is such a type.This PR adjusts the definition of 'incompatible with await' such that
X & S
is incompatible with await whenS
is incompatible with await. This is a bit more strict than the previous version. It is motivated by the fact that a promotion of a variable of typeX
to a typeX & S
whereS
isn't compatible with await is a strong signal that it should not be awaited.Of course,
await (e as T)
for some suitable value ofT
can always be used to force the await.The change is not breaking because 'incompatible with await' has not yet been implemented in any release.