oven-sh/bun · error · Error

Expected type for argument ${name}, got ${inspect(type)}

Error message

Expected type for argument ${name}, got ${inspect(type)}

What it means

Error "Expected type for argument ${name}, got ${inspect(type)}" thrown in oven-sh/bun.

Source

Thrown at src/codegen/bindgen-lib-internal.ts:835

    [isFunc]: true,
    name: "",
    snapshot,
    sourceFile,
    variants,
  };
  allFunctions.push(func);
  file.functions.push(func);
  return func;
}

function validateVariant(variant: any) {
  let minRequiredArgs = 0;
  let seenOptionalArgument = false;
  let i = 0;

  for (const [name, type] of Object.entries(variant.args) as [string, TypeImpl][]) {
    if (!(type instanceof TypeImpl)) {
      throw new Error(`Expected type for argument ${name}, got ${inspect(type)}`);
    }
    i += 1;
    if (type.isVirtualArgument()) {
      continue;
    }
    if (!type.flags.optional && !("default" in type.flags)) {
      if (seenOptionalArgument) {
        throw new Error(`Required argument ${name} cannot follow an optional argument`);
      }
      minRequiredArgs++;
    } else {
      seenOptionalArgument = true;
    }
  }

  return { minRequiredArgs };
}

View on GitHub (pinned to 8c5296ac45)

When it happens

Trigger: Thrown at src/codegen/bindgen-lib-internal.ts:835 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/e36e5298a970dbe5. Report an issue: GitHub.