You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
printer.printNode stripping text within html tags #27216
Search Terms:
printNode JSX
printNode not printing JSX text
Code
consthtml='<div>Text within a node</div>';constjsxAst=ts.createSourceFile('test-file.tsx',html,ts.ScriptTarget.Latest,false,ts.ScriptKind.TSX,);constprinter=ts.createPrinter({newLine: ts.NewLineKind.LineFeed,});constresult=printer.printNode(ts.EmitHint.Unspecified,jsxAst,jsxAst);
Expected behavior:
Value of the result variable should be the same as the html variable
I cannot reproduce this. I tried adding the following test case to src\testRunner\unittests\printer.ts and got the expected result:
printsCorrectly("JsxText",{},printer=>{consthtml='<div>Text within a node</div>';constjsxAst=ts.createSourceFile('test-file.tsx',html,ts.ScriptTarget.Latest,false,ts.ScriptKind.TSX,);returnprinter.printNode(ts.EmitHint.Unspecified,jsxAst,jsxAst);});
It is possible there was an error with either parent pointers or setting the .text property of a JsxText node that has been subsequently fixed.
Activity
fix printer.printNode stripping text within html tags see microsoft#2…
rbuckton commentedon May 9, 2019
I cannot reproduce this. I tried adding the following test case to
src\testRunner\unittests\printer.tsand got the expected result:It is possible there was an error with either parent pointers or setting the
.textproperty of a JsxText node that has been subsequently fixed.rbuckton commentedon May 9, 2019
It looks like this was fixed by #29439.