Do not emit comments if container had a comment suppression.

This commit is contained in:
Martin Probst 2018-07-18 17:22:18 +02:00
parent 2529b864f4
commit a7224ec612
2 changed files with 7 additions and 6 deletions

View file

@ -72,11 +72,13 @@ namespace ts {
const savedContainerEnd = containerEnd;
const savedDeclarationListContainerEnd = declarationListContainerEnd;
if (!skipLeadingComments) {
if (!skipLeadingComments || (pos >= 0 && (emitFlags & EmitFlags.NoLeadingComments) !== 0)) {
// Advance the container position of comments get emitted or if they've been disabled explicitly using NoLeadingComments.
containerPos = pos;
}
if (!skipTrailingComments) {
if (!skipTrailingComments || (end >= 0 && (emitFlags & EmitFlags.NoTrailingComments) !== 0)) {
// As above.
containerEnd = end;
// To avoid invalid comment emit in a down-level binding pattern, we
@ -426,4 +428,4 @@ namespace ts {
return isRecognizedTripleSlashComment(currentText, commentPos, commentEnd);
}
}
}
}

View file

@ -1121,7 +1121,7 @@ namespace ts {
}
// Perform the capture.
captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement);
captureThisForNode(statements, ctor, superCallExpression || createActualThis());
// If we're actually replacing the original statement, we need to signal this to the caller.
if (superCallExpression) {
@ -1443,7 +1443,7 @@ namespace ts {
}
}
function captureThisForNode(statements: Statement[], node: Node, initializer: Expression | undefined, originalStatement?: Statement): void {
function captureThisForNode(statements: Statement[], node: Node, initializer: Expression | undefined): void {
enableSubstitutionsForCapturedThis();
const captureThisStatement = createVariableStatement(
/*modifiers*/ undefined,
@ -1456,7 +1456,6 @@ namespace ts {
])
);
setEmitFlags(captureThisStatement, EmitFlags.NoComments | EmitFlags.CustomPrologue);
setTextRange(captureThisStatement, originalStatement);
setSourceMapRange(captureThisStatement, node);
statements.push(captureThisStatement);
}