Skip to content

printer.printNode stripping text within html tags #27216

Description

@yulric

TypeScript Version: 3.0.3

Search Terms:
printNode JSX
printNode not printing JSX text

Code

const html = '<div>Text within a node</div>';
const jsxAst = ts.createSourceFile(
    'test-file.tsx',
    html,
    ts.ScriptTarget.Latest,
    false,
    ts.ScriptKind.TSX,
);
const printer = ts.createPrinter({
    newLine: ts.NewLineKind.LineFeed,
});
const result = printer.printNode(ts.EmitHint.Unspecified, jsxAst, jsxAst);

Expected behavior:
Value of the result variable should be the same as the html variable

Actual behavior:
result variable is <div></div>

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions