Skip to content

Commit

Permalink
Remove unnecessary BigInt conditional usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jan 10, 2025
1 parent 4dfd7e0 commit 6484fa6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/babel-parser/src/plugins/estree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ export default (superClass: typeof Parser) =>
// @ts-expect-error ESTree plugin changes node types
parseBigIntLiteral(value: any): N.Node {
// https://github.com/estree/estree/blob/master/es2020.md#bigintliteral
let bigInt: bigint | null;
try {
bigInt = BigInt(value);
} catch {
bigInt = null;
if (!process.env.BABEL_8_BREAKING) {
// eslint-disable-next-line no-var
var bigInt: bigint | null;
try {
bigInt = BigInt(value);
} catch {
bigInt = null;
}
}
const node = this.estreeParseLiteral<N.EstreeBigIntLiteral>(bigInt);
const node = this.estreeParseLiteral<N.EstreeBigIntLiteral>(
process.env.BABEL_8_BREAKING ? BigInt(value) : bigInt,
);
node.bigint = String(node.value || value);

return node;
Expand Down

0 comments on commit 6484fa6

Please sign in to comment.