Uncalled function checks only works with single conditional - #42835
Conversation
611f5b3 to
e848beb
Compare
|
TypeScript Bot (@typescript-bot) user test this Jonas Hübotter (@jonhue) A couple of things to do next:
|
|
Heya Nathan Shively-Sanders (@sandersn), I've started to run the parallelized Definitely Typed test suite on this PR at 745a34c. You can monitor the build here. |
|
Heya Nathan Shively-Sanders (@sandersn), I've started to run the parallelized community code test suite on this PR at 745a34c. You can monitor the build here. |
|
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
|
Nathan Shively-Sanders (@sandersn) Thank you for your comment! I skimmed through the test suite run and the errors look reasonable to me. |
|
|
||
| const location = isBinaryExpression(condExpr) ? condExpr.right : condExpr; | ||
| if (isBinaryExpression(condExpr) && condExpr.operatorToken.kind === SyntaxKind.BarBarToken) { | ||
| checkTestingKnownTruthyCallableOrAwaitableType(condExpr.left, type, body); |
There was a problem hiding this comment.
I don't think recursion is a good idea here, because binary expressions might be pretty long, and because the core of checkTestingKnownTruthyCallableOrAwaitableType is not too complex.
I'd move the getSignatureOfType check before location's declaration, then put the rest of the function in a helper that's called in a loop, something like:
helper(condExpr, body)
while (isBinaryExpression(condExpr) && condExpr.operatorToken.kind === SyntaxKind.BarBarToken) {
condExpr = condExpr.left
helper(condExpr, body)
}(although you might be able to write it more elegantly)
| // error | ||
| } | ||
|
|
||
| if (isFoo || isBar) { |
There was a problem hiding this comment.
just for safety, can you add a test like x || y || z() || foo?
|
Actually, looking at the whole call chain, I think |
|
Nathan Shively-Sanders (@sandersn) Thank you for your comments! You're right, we do need to check the type per |
8ca5cdf to
e2e6330
Compare
|
I like the code as-is, but it checks a lot more than before. I want to see whether there are many new errors in the user tests: TypeScript Bot (@typescript-bot) user test this Jonas Hübotter (@jonhue) can you take a look at those after they're done running? Edit: I'll sign off if you find that there aren't a lot of bogus errors appearing. |
|
Heya Nathan Shively-Sanders (@sandersn), I've started to run the parallelized community code test suite on this PR at de23735. You can monitor the build here. |
|
Heya Nathan Shively-Sanders (@sandersn), I've started to run the parallelized Definitely Typed test suite on this PR at de23735. You can monitor the build here. |
|
Nathan Shively-Sanders (@sandersn) looks like something went wrong while running the tests. I can't really gather from the logs what exactly went wrong. Could you take a brief look/rerun the tests? 🙂 |
|
TypeScript Bot (@typescript-bot) user test this |
|
Heya Nathan Shively-Sanders (@sandersn), I've started to run the parallelized Definitely Typed test suite on this PR at c973b9b. You can monitor the build here. |
|
Heya Nathan Shively-Sanders (@sandersn), I've started to run the parallelized community code test suite on this PR at c973b9b. You can monitor the build here. |
|
No report from typescript-bot again =( I manually checked the DT run and there weren't any new failures. It looks like the user test run failed to post a comment after it successfully pushed to the existing PR at https://github.com/typescript-bot/TypeScript/pull/158/files I looked at the existing PR and saw two new errors: the fluentui one is good. It looks like the author forgot that |
|
Since this is a new feature, I'll merge this after the 4.3 beta is done. |
|
The TypeScript team hasn't accepted the linked issue #35584. If you can get it accepted, this PR will have a better chance of being reviewed. |
|
Thank you all for your work in this 👍 Glad to see it added |
This pull request makes two changes:
||binary expressions for uncalled functions (not just the rightmost ones)!unary expressions for uncalled functions (if the function cannot beundefined)Fixes #35584