Skip to content

Conversation

@andrewbranch
Copy link
Member

Um, so in #32239, one of the ones I added was

declare var x: Promise<number>;
x++; // Did you forget to use 'await'?
--x; // Did you forget to use 'await'?

🤦‍♂

Did you forget to use 'await'? Did you really?

// Obviously nonsense
(await x)++;
--(await x);

image

}

function checkArithmeticOperandType(operand: Node, type: Type, diagnostic: DiagnosticMessage): boolean {
function checkArithmeticOperandType(operand: Node, type: Type, diagnostic: DiagnosticMessage, tryAwait = false): boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sold on the parameter name. Seems more like 'suggestAwait' or something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether await is actually suggested is left up to some additional checks performed in the function; it could be trySuggestAwait or maybeSuggestAwait or isAwaitValid. I think the last sounds best. Thanks 👍

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 best dog

@andrewbranch andrewbranch merged commit 00e7d9c into microsoft:master Jul 10, 2019
@andrewbranch andrewbranch deleted the no-missing-await-on-unary-arithmetic-expressions branch July 10, 2019 21:31
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants