mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Fix single-line comment disrupting return w/optional chain (#42026)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user