8000 Printer incorrectly adding line break when emitting node list with non-synthesized nodes as of TS 4.3 Β· Issue #44068 Β· microsoft/TypeScript Β· GitHub
[go: up one dir, main page]

8000
Skip to content
Printer incorrectly adding line break when emitting node list with non-synthesized nodes as of TS 4.3Β #44068
Closed
@devversion

Description

@devversion

Bug Report

πŸ”Ž Search Terms

printer, line break, ts 4.3, beta, for non-synthesized nodes, line separator, new line.

πŸ•— Version & Regression Information

Started as of v4.3-dev.

⏯ Playground Link

Specific to the compiler API; not reproduce in the playground.

πŸ’» Code

Reproduction repository: https://github.com/devversion/ts-4.3-emitter-node-list-line-breaks

Consider an input file as the followed:

const FirstSymbol = Symbol();
const SecondSymbol = Symbol();

Assume we have the AST for this source file and have access to these variables. i.e. firstVarNode and secondVarNode. If we construct a new array literal containing the names of these variables and print the array literal, the array literal will be multi-line.

const arrayLiteral = ts.createArrayLiteral([
    firstVarNode.name,
    secondVarNode.name
]);

console.log(printer.printNode(ts.EmitHint.Unspecified, arrayLiteral, testFile));

the output will be:

[FirstSymbol,
    SecondSymbol]

while I'd expect it to be [FirstSymbol, SecondSymbol] unless I specify multiLine = true for the array literal expression.

Additional information

This seems to have changed with 3c32f6e. The printer now checks if the non-synthesized nodes are on the same line, even if they do not have the same parent.

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0