Closed ChrML closed 1 year ago
Short answer: full fidelity (or concrete) syntax (including trivia) is not supported currently.
Long answer: Esprima is based on the ESTree specification, which doesn't implement full fidelity syntax. There is an open proposal though, without a clear perspective.
But even if such thing gets spec'ed, it's unlikely that it will ever land here. Besides the fact that implementing it would be a huge amount of work, there are also other aspects to take into account:
[...] because its main consumer is Jint, which wouldn't want to pay the price of a more detailed AST model.
(Quote from a related discussion).
So, I'm pretty certain that full fidelity syntax can only happen in a fork.
I can't find any way to keep the trivia (whitespace, line-shifts etc...) when parsing the syntax-tree. Ideally, a roundtrip from a Javascript string, to AST and back to a Javascript string should in my case give the exact same string (like the Microsoft.CodeAnalysis.CSharp syntax tree). Is there a plan for a feature like this?