mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 16:39:46 -05:00
add a new line if after writing trailing comments (#12894)
This commit is contained in:
@@ -156,6 +156,9 @@ namespace ts {
|
||||
|
||||
if (!skipTrailingComments) {
|
||||
emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true);
|
||||
if (hasWrittenComment && !writer.isAtStartOfLine()) {
|
||||
writer.writeLine();
|
||||
}
|
||||
}
|
||||
|
||||
if (extendedDiagnostics) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
18
tests/baselines/reference/systemModuleTrailingComments.js
Normal file
18
tests/baselines/reference/systemModuleTrailingComments.js
Normal 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
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
=== tests/cases/compiler/systemModuleTrailingComments.ts ===
|
||||
export const test = "TEST";
|
||||
>test : Symbol(test, Decl(systemModuleTrailingComments.ts, 0, 12))
|
||||
|
||||
//some comment
|
||||
@@ -0,0 +1,6 @@
|
||||
=== tests/cases/compiler/systemModuleTrailingComments.ts ===
|
||||
export const test = "TEST";
|
||||
>test : "TEST"
|
||||
>"TEST" : "TEST"
|
||||
|
||||
//some comment
|
||||
4
tests/cases/compiler/systemModuleTrailingComments.ts
Normal file
4
tests/cases/compiler/systemModuleTrailingComments.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// @module: system
|
||||
export const test = "TEST";
|
||||
|
||||
//some comment
|
||||
Reference in New Issue
Block a user