Fix single-line comment disrupting return w/optional chain (#42026)

This commit is contained in:
Ron Buckton
2020-12-17 18:55:09 -08:00
committed by GitHub
parent 052d7308e6
commit e789cb1356
3 changed files with 22 additions and 6 deletions

View File

@@ -77,7 +77,6 @@ namespace ts {
if (!isSimpleCopiableExpression(expression)) {
thisArg = factory.createTempVariable(hoistVariableDeclaration);
expression = factory.createAssignment(thisArg, expression);
// if (inParameterInitializer) tempVariableInParameter = true;
}
else {
thisArg = expression;
@@ -117,7 +116,6 @@ namespace ts {
if (!isSimpleCopiableExpression(leftExpression)) {
capturedLeft = factory.createTempVariable(hoistVariableDeclaration);
leftExpression = factory.createAssignment(capturedLeft, leftExpression);
// if (inParameterInitializer) tempVariableInParameter = true;
}
let rightExpression = capturedLeft;
let thisArg: Expression | undefined;
@@ -130,7 +128,6 @@ namespace ts {
if (!isSimpleCopiableExpression(rightExpression)) {
thisArg = factory.createTempVariable(hoistVariableDeclaration);
rightExpression = factory.createAssignment(thisArg, rightExpression);
// if (inParameterInitializer) tempVariableInParameter = true;
}
else {
thisArg = rightExpression;
@@ -163,6 +160,7 @@ namespace ts {
const target = isDelete
? factory.createConditionalExpression(createNotNullCondition(leftExpression, capturedLeft, /*invert*/ true), /*questionToken*/ undefined, factory.createTrue(), /*colonToken*/ undefined, factory.createDeleteExpression(rightExpression))
: factory.createConditionalExpression(createNotNullCondition(leftExpression, capturedLeft, /*invert*/ true), /*questionToken*/ undefined, factory.createVoidZero(), /*colonToken*/ undefined, rightExpression);
setTextRange(target, node);
return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target;
}
@@ -188,15 +186,14 @@ namespace ts {
if (!isSimpleCopiableExpression(left)) {
right = factory.createTempVariable(hoistVariableDeclaration);
left = factory.createAssignment(right, left);
// if (inParameterInitializer) tempVariableInParameter = true;
}
return factory.createConditionalExpression(
return setTextRange(factory.createConditionalExpression(
createNotNullCondition(left, right),
/*questionToken*/ undefined,
right,
/*colonToken*/ undefined,
visitNode(node.right, visitor, isExpression),
);
), node);
}
function visitDeleteExpression(node: DeleteExpression) {