oxc icon indicating copy to clipboard operation
oxc copied to clipboard

transformer: `2n ** 32n` gets transformed into runtime error `Math.pow(2n, 32n)`

Open Boshen opened this issue 1 year ago • 3 comments

I think we need to bail in this case :-/

tsc and esbuild throws "BigInt literals are not available when targeting lower than ES2020."

Boshen avatar Sep 17 '24 09:09 Boshen

Background on why it's not feasible to support BigInt with a polyfill: https://github.com/evanw/esbuild/issues/732

It looks like we should bail on any BigInt literal, not just when used with **.

Side note: Math.pow with any BigInt values is a runtime error, they don't have to be big numbers. e.g. Math.pow(1n, 1n) is a runtime error.

overlookmotel avatar Sep 17 '24 09:09 overlookmotel

@Dunqing How do we determine whether https://babel.dev/docs/babel-plugin-syntax-bigint is enabled or not in our transformer?

Boshen avatar Sep 23 '24 13:09 Boshen

@Dunqing need to figure out whether bigint is targeted or not.

Boshen avatar Sep 24 '24 10:09 Boshen