Do not incorrectly add line separators for non-synthetic nodes when emitting node list (#44070)

As of 3c32f6e154, a line separator is
added between nodes if the nodes are not synthetic and on separate
lines. This it push s wrong and previously only happened if the non-synthetic
nodes were on different lines but had the same parent.

Fixes #44068.
This commit is contained in:
Paul Gschwendtner
2021-06-04 09:46:23 -05:00
committed by GitHub
parent a7fb678c03
commit b26f77a703
10 changed files with 61 additions and 24 deletions
+20
View File
@@ -154,6 +154,26 @@ namespace ts {
}).outputText;
});
testBaseline("issue44068", () => {
return transformSourceFile(`
const FirstVar = null;
const SecondVar = null;
`, [
context => file => {
const firstVarName = (file.statements[0] as VariableStatement)
.declarationList.declarations[0].name as Identifier;
const secondVarName = (file.statements[0] as VariableStatement)
.declarationList.declarations[0].name as Identifier;
return context.factory.updateSourceFile(file, file.statements.concat([
context.factory.createExpressionStatement(
context.factory.createArrayLiteralExpression([firstVarName, secondVarName])
),
]));
}
]);
});
testBaseline("rewrittenNamespace", () => {
return transpileModule(`namespace Reflect { const x = 1; }`, {
transformers: {