Skip to content
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

Remove "Did you forget to use await" for unary arithmetic expressions #32334

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

@@ -23713,9 +23713,9 @@ namespace ts {
}
}

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants