babel/babel · error · Error

The 'discardBinding' plugin requires a 'syntaxType' option.

Error message

The 'discardBinding' plugin requires a 'syntaxType' option. Currently the only supported value is 'void'.

What it means

Thrown when the 'discardBinding' parser plugin is enabled but its `syntaxType` option is missing or not 'void'. Discard bindings (the ability to declare a parameter that is explicitly unused) currently only support the `void` keyword form (e.g. function f(void) {}). Requiring the explicit option future-proofs the API if more syntaxes are added.

Source

Thrown at packages/babel-parser/src/plugin-utils.ts:123

    throw error;
  }

  if (
    pluginsMap.has("optionalChainingAssign") &&
    pluginsMap.get("optionalChainingAssign").version !== "2023-07"
  ) {
    throw new Error(
      "The 'optionalChainingAssign' plugin requires a 'version' option," +
        " representing the last proposal update. Currently, the" +
        " only supported value is '2023-07'.",
    );
  }

  if (
    pluginsMap.has("discardBinding") &&
    pluginsMap.get("discardBinding").syntaxType !== "void"
  ) {
    throw new Error(
      "The 'discardBinding' plugin requires a 'syntaxType' option. Currently the only supported value is 'void'.",
    );
  }

  if (pluginsMap.has("decimal")) {
    throw new Error(
      "The 'decimal' plugin has been removed in Babel 8. Please remove it from your configuration.",
    );
  }
  if (pluginsMap.has("importReflection")) {
    throw new Error(
      "The 'importReflection' plugin has been removed in Babel 8. Use 'sourcePhaseImports' instead, and " +
        "replace 'import module' with 'import source' in your code.",
    );
  }
}

// These plugins are defined using a mixin which extends the parser class.

View on GitHub (pinned to 06b6eae39d)

Solutions

  1. Pass the required option: ['discardBinding', { syntaxType: 'void' }].
  2. Remove the plugin if you are not using `void` discard bindings.

Example fix

// before
parserPlugins: ['discardBinding']

// after
parserPlugins: [['discardBinding', { syntaxType: 'void' }]]
Defensive patterns

Strategy: validation

Validate before calling

function normalizeDiscardBinding(plugins) {
  return plugins.map(p => {
    if (Array.isArray(p) && p[0] === 'discardBinding') {
      return ['discardBinding', { syntaxType: 'void', ...(p[1] || {}) }];
    }
    return p;
  });
}

Type guard

function hasValidDiscardBindingSyntaxType(plugins) {
  const p = plugins.find(x => Array.isArray(x) && x[0] === 'discardBinding');
  return !p || (p[1] && p[1].syntaxType === 'void');
}

Prevention

When it happens

Trigger: Listing ['discardBinding'] with no options object, or with a syntaxType other than 'void'.

Common situations: Enabling the plugin without reading its options contract. Following an early-proposal draft that did not require syntaxType.

Related errors


AI-assisted analysis of babel/babel@06b6eae39d (2026-08-03). Data as JSON: /data/errors/481590e5bf314679.json. Report an issue: GitHub.