oxc-project/oxc · error · OxcDiagnostic

Big integer literals are not available in the configured tar

Error message

Big integer literals are not available in the configured target environment.

What it means

Warning raised by the oxc transformer's ES2020 pass (crates/oxc_transformer/src/es2020/mod.rs, `enter_big_int_literal`). When the ES2020 options enable `big_int` — which happens when the compile target predates ES2020 — and the traversal reaches a `BigIntLiteral` node (e.g. `123n`), the pass records this diagnostic via `ctx.state.error`. There is no way to downlevel a BigInt literal for pre-ES2020 environments (Babel likewise errors instead of transforming), so oxc reports and leaves the literal in place; running the output on an old target throws SyntaxError.

Source

Thrown at crates/oxc_transformer/src/es2020/mod.rs:75

    ) {
        if self.options.optional_chaining {
            self.optional_chaining.enter_formal_parameters(node, ctx);
        }
    }

    fn exit_formal_parameters(
        &mut self,
        node: &mut FormalParameters<'a>,
        ctx: &mut TraverseCtx<'a>,
    ) {
        if self.options.optional_chaining {
            self.optional_chaining.exit_formal_parameters(node, ctx);
        }
    }

    fn enter_big_int_literal(&mut self, node: &mut BigIntLiteral<'a>, ctx: &mut TraverseCtx<'a>) {
        if self.options.big_int {
            let warning = OxcDiagnostic::warn(
                "Big integer literals are not available in the configured target environment.",
            )
            .with_label(node.span);
            ctx.state.error(warning);
        }
    }

    fn enter_import_specifier(
        &mut self,
        node: &mut ImportSpecifier<'a>,
        ctx: &mut TraverseCtx<'a>,
    ) {
        if self.options.arbitrary_module_namespace_names
            && let ModuleExportName::StringLiteral(literal) = &node.imported
        {
            let warning = OxcDiagnostic::warn(
                "Arbitrary module namespace identifier names are not available in the configured target environment.",
            )

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Raise the build target to ES2020 or later (browserslist config, `target: 'es2020'` in oxc-transform options) so the `big_int` transform is disabled.
  2. Replace literals with constructor calls: `BigInt('123')` works in any runtime that has BigInt; if the runtime lacks BigInt entirely, use a bigint polyfill/bn.js.
  3. Remove the BigInt usage (use numbers or strings for IDs).
  4. If you must stay pre-ES2020, use a dedicated bigint transform plugin (e.g. babel-plugin-transform-bigint) in a separate pass — oxc does not provide one.

Example fix

// before (target: es2018)
const id = 9007199254740993n;

// after
const id = BigInt('9007199254740993');
Defensive patterns

Strategy: validation

Validate before calling

// Check source for BigInt literals before transforming for a pre-ES2020 target
if (/\b\d+n\b/.test(source)) {
  throw new Error('Source contains BigInt literals; raise the target to ES2020+ or convert to BigInt("...") calls');
}

Try / catch

// oxc-transform returns diagnostics instead of throwing — inspect them
import { transform } from 'oxc-transform';
const result = transform('foo.ts', source, { target: 'es2018' });
if (result.errors.length > 0) {
  for (const err of result.errors) console.error(err.message); // 'Big integer literals are not available...'
  process.exit(1);
}

Prevention

When it happens

Trigger: Transforming source containing BigInt literals (`10n`, `0xFFn`, `1_000_000n`) with an oxc-transformer/oxc-transform ES target below ES2020 (options.big_int enabled, e.g. targets like chrome 60 or es2015/es2017). Each BigIntLiteral node in the program produces one error labeled with the literal's span.

Common situations: Browserslist/babel targets left at legacy defaults (older Safari, IE11-era configs) while dependencies or app code use `BigInt` literals; upgrading a dependency that starts shipping `n` literals without bumping the build target; using IDs stored as BigInt literals in a codebase built for old runtimes.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/a999a2f6ada90da6. Report an issue: GitHub.