question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible string / number literal printing bug

See original GitHub issue

Literals 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:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dsherretcommented, Oct 13, 2018

This will be fixed in 17.0.1 (just releasing now). Thanks again!

1reaction
dsherretcommented, Oct 13, 2018

Oh wait, there’s definitely a problem here with printNode. Passing in the source file is a temporary workaround though. Thanks for reporting!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found