-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Issue unawaited promise error on symbol-less expressions #44491
Conversation
const testedSymbol = getSymbolAtLocation(testedNode); | ||
if (!testedSymbol) { | ||
const testedSymbol = testedNode && getSymbolAtLocation(testedNode); | ||
if (!testedSymbol && !isPromise) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t know that we actually need have divergent behavior for unawaited promises and uncalled expressions here—what do we expect for something like
const or = x => y => x || y;
if (or(true)) { // today: no error, but maybe should be?
// ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expanding it to uncalled functions seems like an improvement to me. We just need to know that it won't break lots of existing code. Are you up for checking DT and RWC to see?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, although you are right that maybe it should apply to uncalled functions too.
const testedSymbol = getSymbolAtLocation(testedNode); | ||
if (!testedSymbol) { | ||
const testedSymbol = testedNode && getSymbolAtLocation(testedNode); | ||
if (!testedSymbol && !isPromise) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expanding it to uncalled functions seems like an improvement to me. We just need to know that it won't break lots of existing code. Are you up for checking DT and RWC to see?
@typescript-bot test this |
Heya @andrewbranch, I've started to run the extended test suite on this PR at 60d5813. You can monitor the build here. |
Heya @andrewbranch, I've started to run the parallelized Definitely Typed test suite on this PR at 60d5813. You can monitor the build here. |
Heya @andrewbranch, I've started to run the parallelized community code test suite on this PR at 60d5813. You can monitor the build here. |
This reverts commit 60d5813.
Test infrastructure seemed to be having an issue, so I’m not going to worry about aligning the call expression behavior for now, which would be a breaking change that we haven’t validated. We can revisit in the future but I’d probably lean toward waiting to hear user feedback. |
Makes #43593 less conservative. Previously, since we wanted to check whether the body of the conditional references the same thing that’s being tested for truthiness, we had to get a symbol for the
if
expression and find references to that same symbol. We can only find symbols on identifiers and access expressions, so we failed to come up with a suitable location on call expressions like the one in the blog post:This PR adds the error back in cases like these where we can’t easily tell whether or not the expression is used again in the function body.