Possible string / number literal printing bug
See original GitHub issueLiterals not printed with printNode Version: 14.4.3
function printNode does not print string literals like “hello” or number literals like 555 To Reproduce
import Project, {printNode} from "ts-simple-ast";
const project = new Project();
const sourceFile = project.createSourceFile("test.ts", `
function test() {
return 555
}
`);
sourceFile.getFunctions().forEach( f => {
// does not emit literal 555
console.log(printNode(f.compilerNode))
})
Expected behavior
Should print the function code
function test() {
return 555
}
currently prints
function test() {
return ;
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
The template function encountered an error when passed in a ...
The template function encountered an error when passed in a numeric literal, but string literals didn't ; include <iostream> ; include <string> ...
Read more >Literals in Programming Languages
Literals represent the possible choices in primitive types for that language. Some of the choices of types of literals are often integers, ...
Read more >7.11 Print Statements | Stan Reference Manual
The text printed by a print statement varies based on its content. A literal (i.e., quoted) string in a print statement always prints...
Read more >String literal - Wikipedia
A string literal or anonymous string is a string value in the source code of a computer program. Modern programming languages commonly use...
Read more >AWK Language Programming - Printing Output - Math
The items to be printed can be constant strings or numbers, fields of the current record (such as $1 ), variables, or any...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This will be fixed in 17.0.1 (just releasing now). Thanks again!
Oh wait, there’s definitely a problem here with
printNode
. Passing in the source file is a temporary workaround though. Thanks for reporting!