New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix printing BigIntLiterals/DecimalLiterals with compact option #12424
Conversation
existentialism
commented
Nov 30, 2020
•
edited by gitpod-io
bot
edited by gitpod-io
bot
Q | A |
---|---|
Fixed Issues? | Fixes #12423 |
Patch: Bug Fix? | Y |
License | MIT |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/33642/ |
@@ -216,19 +216,19 @@ export function StringLiteral(node: Object) { | |||
export function BigIntLiteral(node: Object) { | |||
const raw = this.getPossibleRaw(node); | |||
if (!this.format.minified && raw != null) { | |||
this.token(raw); | |||
this.word(raw); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolo-ribaudo @JLHwung we could also use this.number
here if clearer (though there's logic in there for handling integer tokens), thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's add a comment explaining that we use word
instead of number
to avoid that additional logic?
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 84fb9a1:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could add a compact: true
test runner for @babel/generator
, like we did for estree
in @babel/parser
. Essentially we shall enforce the following idempotent invariance:
generate(ast, { compact: true }) === generate(parse(generate(ast, { compact: true })), { compact: true })
@JLHwung yeah been thinking of doing this for a while, will take a look |