Bind RHS of comma expressions too (#47049)

This commit is contained in:
Jake Bailey
2022-01-18 11:46:09 -08:00
committed by GitHub
parent 16e96f62d7
commit e2c00331d6
5 changed files with 163 additions and 9 deletions

View File

@@ -1365,7 +1365,7 @@ namespace ts {
}
function maybeBindExpressionFlowIfCall(node: Expression) {
// A top level or LHS of comma expression call expression with a dotted function name and at least one argument
// A top level or comma expression call expression with a dotted function name and at least one argument
// is potentially an assertion and is therefore included in the control flow.
if (node.kind === SyntaxKind.CallExpression) {
const call = node as CallExpression;
@@ -1550,24 +1550,29 @@ namespace ts {
return state;
}
function onLeft(left: Expression, state: WorkArea, _node: BinaryExpression) {
function onLeft(left: Expression, state: WorkArea, node: BinaryExpression) {
if (!state.skip) {
return maybeBind(left);
const maybeBound = maybeBind(left);
if (node.operatorToken.kind === SyntaxKind.CommaToken) {
maybeBindExpressionFlowIfCall(left);
}
return maybeBound;
}
}
function onOperator(operatorToken: BinaryOperatorToken, state: WorkArea, node: BinaryExpression) {
function onOperator(operatorToken: BinaryOperatorToken, state: WorkArea, _node: BinaryExpression) {
if (!state.skip) {
if (operatorToken.kind === SyntaxKind.CommaToken) {
maybeBindExpressionFlowIfCall(node.left);
}
bind(operatorToken);
}
}
function onRight(right: Expression, state: WorkArea, _node: BinaryExpression) {
function onRight(right: Expression, state: WorkArea, node: BinaryExpression) {
if (!state.skip) {
return maybeBind(right);
const maybeBound = maybeBind(right);
if (node.operatorToken.kind === SyntaxKind.CommaToken) {
maybeBindExpressionFlowIfCall(right);
}
return maybeBound;
}
}