Fix printing BigIntLiterals/DecimalLiterals with compact option (#12424)
This commit is contained in:
parent
2ca28d78e6
commit
7018ed6e46
@ -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) {
|
||||
|
||||
5
packages/babel-generator/test/fixtures/types/BigIntLiteral-compact/input.js
vendored
Normal file
5
packages/babel-generator/test/fixtures/types/BigIntLiteral-compact/input.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
function a() { return 100n; }
|
||||
function b() { return 9223372036854775807n; }
|
||||
function c() { return 0o16432n; }
|
||||
function d() { return 0xFFF123n; }
|
||||
function e() { return 0b101011101n; }
|
||||
3
packages/babel-generator/test/fixtures/types/BigIntLiteral-compact/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/types/BigIntLiteral-compact/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"compact": true
|
||||
}
|
||||
1
packages/babel-generator/test/fixtures/types/BigIntLiteral-compact/output.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/types/BigIntLiteral-compact/output.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
function a(){return 100n;}function b(){return 9223372036854775807n;}function c(){return 0o16432n;}function d(){return 0xFFF123n;}function e(){return 0b101011101n;}
|
||||
5
packages/babel-generator/test/fixtures/types/DecimalLiteral-compact/input.js
vendored
Normal file
5
packages/babel-generator/test/fixtures/types/DecimalLiteral-compact/input.js
vendored
Normal file
@ -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; }
|
||||
4
packages/babel-generator/test/fixtures/types/DecimalLiteral-compact/options.json
vendored
Normal file
4
packages/babel-generator/test/fixtures/types/DecimalLiteral-compact/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"compact": true,
|
||||
"plugins": ["decimal"]
|
||||
}
|
||||
1
packages/babel-generator/test/fixtures/types/DecimalLiteral-compact/output.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/types/DecimalLiteral-compact/output.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
function a(){return 100m;}function b(){return 9223372036854775807m;}function c(){return 0.m;}function d(){return 3.1415926535897932m;}function e(){return 100.000m;}
|
||||
Loading…
x
Reference in New Issue
Block a user