fix: numeric separators were removed from BigInt literals (#6796)
parent
12ba997207
commit
6ba4be015b
|
@ -1351,6 +1351,20 @@ $ prettier --stdin-filepath does/not/exist.js < test.js
|
||||||
test;
|
test;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### JavaScript: Numeric separators were removed from BigInt literals ([#6796] by [@thorn0])
|
||||||
|
|
||||||
|
<!-- prettier-ignore -->
|
||||||
|
```js
|
||||||
|
// Input
|
||||||
|
const bigints = [200_000n, 0x0000_000An, 0b0111_1111n];
|
||||||
|
|
||||||
|
// Output (Prettier stable)
|
||||||
|
const bigints = [200000n, 0x0000000an, 0b01111111n];
|
||||||
|
|
||||||
|
// Output (Prettier master)
|
||||||
|
const bigints = [200_000n, 0x0000_000an, 0b0111_1111n];
|
||||||
|
```
|
||||||
|
|
||||||
[#5682]: https://github.com/prettier/prettier/pull/5682
|
[#5682]: https://github.com/prettier/prettier/pull/5682
|
||||||
[#6657]: https://github.com/prettier/prettier/pull/6657
|
[#6657]: https://github.com/prettier/prettier/pull/6657
|
||||||
[#5910]: https://github.com/prettier/prettier/pull/5910
|
[#5910]: https://github.com/prettier/prettier/pull/5910
|
||||||
|
@ -1398,6 +1412,7 @@ test;
|
||||||
[#6728]: https://github.com/prettier/prettier/pull/6728
|
[#6728]: https://github.com/prettier/prettier/pull/6728
|
||||||
[#6708]: https://github.com/prettier/prettier/pull/6708
|
[#6708]: https://github.com/prettier/prettier/pull/6708
|
||||||
[#6687]: https://github.com/prettier/prettier/pull/6687
|
[#6687]: https://github.com/prettier/prettier/pull/6687
|
||||||
|
[#6796]: https://github.com/prettier/prettier/pull/6796
|
||||||
[@brainkim]: https://github.com/brainkim
|
[@brainkim]: https://github.com/brainkim
|
||||||
[@duailibe]: https://github.com/duailibe
|
[@duailibe]: https://github.com/duailibe
|
||||||
[@gavinjoyce]: https://github.com/gavinjoyce
|
[@gavinjoyce]: https://github.com/gavinjoyce
|
||||||
|
|
|
@ -1610,15 +1610,8 @@ function printPathNoParens(path, options, print, args) {
|
||||||
case "NumericLiteral": // Babel 6 Literal split
|
case "NumericLiteral": // Babel 6 Literal split
|
||||||
return printNumber(n.extra.raw);
|
return printNumber(n.extra.raw);
|
||||||
case "BigIntLiteral":
|
case "BigIntLiteral":
|
||||||
return concat([
|
// babel: n.extra.raw, typescript: n.raw
|
||||||
printNumber(
|
return (n.extra ? n.extra.raw : n.raw).toLowerCase();
|
||||||
n.extra
|
|
||||||
? n.extra.rawValue
|
|
||||||
: // TypeScript
|
|
||||||
n.value
|
|
||||||
),
|
|
||||||
"n"
|
|
||||||
]);
|
|
||||||
case "BooleanLiteral": // Babel 6 Literal split
|
case "BooleanLiteral": // Babel 6 Literal split
|
||||||
case "StringLiteral": // Babel 6 Literal split
|
case "StringLiteral": // Babel 6 Literal split
|
||||||
case "Literal": {
|
case "Literal": {
|
||||||
|
|
|
@ -14,6 +14,9 @@ printWidth: 80
|
||||||
0XFFF123n
|
0XFFF123n
|
||||||
0b101011101n
|
0b101011101n
|
||||||
0B101011101n
|
0B101011101n
|
||||||
|
200_000n
|
||||||
|
0x0000_000An
|
||||||
|
0b0111_1111n
|
||||||
|
|
||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
100n;
|
100n;
|
||||||
|
@ -24,6 +27,9 @@ printWidth: 80
|
||||||
0xfff123n;
|
0xfff123n;
|
||||||
0b101011101n;
|
0b101011101n;
|
||||||
0b101011101n;
|
0b101011101n;
|
||||||
|
200_000n;
|
||||||
|
0x0000_000an;
|
||||||
|
0b0111_1111n;
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -6,3 +6,6 @@
|
||||||
0XFFF123n
|
0XFFF123n
|
||||||
0b101011101n
|
0b101011101n
|
||||||
0B101011101n
|
0B101011101n
|
||||||
|
200_000n
|
||||||
|
0x0000_000An
|
||||||
|
0b0111_1111n
|
||||||
|
|
Loading…
Reference in New Issue