Skip to content

Commit a7224ec

Browse files
committed
Do not emit comments if container had a comment suppression.
1 parent 2529b86 commit a7224ec

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/compiler/comments.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ namespace ts {
7272
const savedContainerEnd = containerEnd;
7373
const savedDeclarationListContainerEnd = declarationListContainerEnd;
7474

75-
if (!skipLeadingComments) {
75+
if (!skipLeadingComments || (pos >= 0 && (emitFlags & EmitFlags.NoLeadingComments) !== 0)) {
76+
// Advance the container position of comments get emitted or if they've been disabled explicitly using NoLeadingComments.
7677
containerPos = pos;
7778
}
7879

79-
if (!skipTrailingComments) {
80+
if (!skipTrailingComments || (end >= 0 && (emitFlags & EmitFlags.NoTrailingComments) !== 0)) {
81+
// As above.
8082
containerEnd = end;
8183

8284
// To avoid invalid comment emit in a down-level binding pattern, we
@@ -426,4 +428,4 @@ namespace ts {
426428
return isRecognizedTripleSlashComment(currentText, commentPos, commentEnd);
427429
}
428430
}
429-
}
431+
}

src/compiler/transformers/es2015.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ namespace ts {
11211121
}
11221122

11231123
// Perform the capture.
1124-
captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement);
1124+
captureThisForNode(statements, ctor, superCallExpression || createActualThis());
11251125

11261126
// If we're actually replacing the original statement, we need to signal this to the caller.
11271127
if (superCallExpression) {
@@ -1443,7 +1443,7 @@ namespace ts {
14431443
}
14441444
}
14451445

1446-
function captureThisForNode(statements: Statement[], node: Node, initializer: Expression | undefined, originalStatement?: Statement): void {
1446+
function captureThisForNode(statements: Statement[], node: Node, initializer: Expression | undefined): void {
14471447
enableSubstitutionsForCapturedThis();
14481448
const captureThisStatement = createVariableStatement(
14491449
/*modifiers*/ undefined,
@@ -1456,7 +1456,6 @@ namespace ts {
14561456
])
14571457
);
14581458
setEmitFlags(captureThisStatement, EmitFlags.NoComments | EmitFlags.CustomPrologue);
1459-
setTextRange(captureThisStatement, originalStatement);
14601459
setSourceMapRange(captureThisStatement, node);
14611460
statements.push(captureThisStatement);
14621461
}

0 commit comments

Comments
 (0)