add a new line if after writing trailing comments (#12894)

This commit is contained in:
Vladimir Matveev 2016-12-13 12:57:21 -08:00 committed by GitHub
parent e5e1533d49
commit c71e6cc9ef
6 changed files with 49 additions and 12 deletions

View file

@ -156,6 +156,9 @@ namespace ts {
if (!skipTrailingComments) {
emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true);
if (hasWrittenComment && !writer.isAtStartOfLine()) {
writer.writeLine();
}
}
if (extendedDiagnostics) {

View file

@ -101,20 +101,21 @@ namespace ts {
// So the helper will be emit at the correct position instead of at the top of the source-file
const moduleName = tryGetModuleNameFromFile(node, host, compilerOptions);
const dependencies = createArrayLiteral(map(dependencyGroups, dependencyGroup => dependencyGroup.name));
const updated = updateSourceFileNode(
node,
createNodeArray([
createStatement(
createCall(
createPropertyAccess(createIdentifier("System"), "register"),
const updated = setEmitFlags(
updateSourceFileNode(
node,
createNodeArray([
createStatement(
createCall(
createPropertyAccess(createIdentifier("System"), "register"),
/*typeArguments*/ undefined,
moduleName
? [moduleName, dependencies, moduleBodyFunction]
: [dependencies, moduleBodyFunction]
moduleName
? [moduleName, dependencies, moduleBodyFunction]
: [dependencies, moduleBodyFunction]
)
)
)
], node.statements)
);
], node.statements)
), EmitFlags.NoTrailingComments);
if (!(compilerOptions.outFile || compilerOptions.out)) {
moveEmitHelpers(updated, moduleBodyBlock, helper => !helper.scoped);

View file

@ -0,0 +1,18 @@
//// [systemModuleTrailingComments.ts]
export const test = "TEST";
//some comment
//// [systemModuleTrailingComments.js]
System.register([], function (exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var test;
return {
setters: [],
execute: function () {
exports_1("test", test = "TEST");
//some comment
}
};
});

View file

@ -0,0 +1,5 @@
=== tests/cases/compiler/systemModuleTrailingComments.ts ===
export const test = "TEST";
>test : Symbol(test, Decl(systemModuleTrailingComments.ts, 0, 12))
//some comment

View file

@ -0,0 +1,6 @@
=== tests/cases/compiler/systemModuleTrailingComments.ts ===
export const test = "TEST";
>test : "TEST"
>"TEST" : "TEST"
//some comment

View file

@ -0,0 +1,4 @@
// @module: system
export const test = "TEST";
//some comment