Skip to content

Commit

Permalink
Fix printing BigIntLiterals/DecimalLiterals with compact option (#12424)
Browse files Browse the repository at this point in the history
  • Loading branch information
existentialism committed Dec 1, 2020
1 parent 2ca28d7 commit 7018ed6
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/babel-generator/src/generators/types.js
Expand Up @@ -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);
return;
}
this.token(node.value + "n");
this.word(node.value + "n");
}

export function DecimalLiteral(node: Object) {
const raw = this.getPossibleRaw(node);
if (!this.format.minified && raw != null) {
this.token(raw);
this.word(raw);
return;
}
this.token(node.value + "m");
this.word(node.value + "m");
}

export function PipelineTopicExpression(node: Object) {
Expand Down
@@ -0,0 +1,5 @@
function a() { return 100n; }
function b() { return 9223372036854775807n; }
function c() { return 0o16432n; }
function d() { return 0xFFF123n; }
function e() { return 0b101011101n; }
@@ -0,0 +1,3 @@
{
"compact": true
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,5 @@
function a() { return 100m; }
function b() { return 9223372036854775807m; }
function c() { return 0.m; }
function d() { return 3.1415926535897932m; }
function e() { return 100.000m; }
@@ -0,0 +1,4 @@
{
"compact": true,
"plugins": ["decimal"]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7018ed6

Please sign in to comment.