Fix updateBinary operator parameter (#38129)

* Fix `updateBinary` `operator` parameter

There is an issue in `updateBinary` where attempting to update
`operator` without updating `left` or `right` results in a silent no-op.

* Use defaulted parameter in `updateBinary`
This commit is contained in:
Marcel Laverdet
2020-05-05 09:05:02 -07:00
committed by GitHub
parent 94c5c3ff47
commit 44c6cf74cb

View File

@@ -1411,10 +1411,11 @@ namespace ts {
return node;
}
export function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken) {
export function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator: BinaryOperator | BinaryOperatorToken = node.operatorToken) {
return node.left !== left
|| node.right !== right
? updateNode(createBinary(left, operator || node.operatorToken, right), node)
|| node.operatorToken !== operator
? updateNode(createBinary(left, operator, right), node)
: node;
}