More fixes to uncalled function checks in && expressions (#49868)

This commit is contained in:
Andrew Branch
2022-07-22 16:06:16 -07:00
committed by GitHub
parent 4e23f515e0
commit 6aefc1dcea
6 changed files with 534 additions and 1 deletions

View File

@@ -33955,7 +33955,11 @@ namespace ts {
const operator = operatorToken.kind;
if (operator === SyntaxKind.AmpersandAmpersandToken || operator === SyntaxKind.BarBarToken || operator === SyntaxKind.QuestionQuestionToken) {
if (operator === SyntaxKind.AmpersandAmpersandToken) {
const parent = walkUpParenthesizedExpressions(node.parent);
let parent = node.parent;
while (parent.kind === SyntaxKind.ParenthesizedExpression
|| isBinaryExpression(parent) && (parent.operatorToken.kind === SyntaxKind.AmpersandAmpersandToken || parent.operatorToken.kind === SyntaxKind.BarBarToken)) {
parent = parent.parent;
}
checkTestingKnownTruthyCallableOrAwaitableType(node.left, isIfStatement(parent) ? parent.thenStatement : undefined);
}
checkTruthinessOfType(leftType, node.left);