biomejs/biome · error
Promise constructor must have one required executor paramete
Error message
Promise constructor must have one required executor parameter
What it means
The Promise constructor's construct signature is required to take exactly one required executor parameter (the `(resolve, reject) => void` callback). This bail fires when the signature has zero required formal parameters, more than one, or when the single executor parameter is optional. It enforces the ECMAScript `new Promise(executor)` shape during codegen.
Source
Thrown at xtask/codegen/src/generate_global_types/lower.rs:1095
}
if !saw_value {
bail!("Promise global must include declare var Promise");
}
Ok(())
}
/// Requires the executor and return shapes represented by the synthetic constructor helper.
fn validate_promise_construct_signature(member: &TsConstructSignatureTypeMember) -> Result<()> {
single_type_parameter_name(member.type_parameters(), "Promise constructor")?;
let mut parameters = member.parameters()?.items().into_iter();
let executor = required_formal_parameter(
parameters.next(),
"Promise constructor",
"one executor parameter",
)?;
if parameters.next().is_some() || executor.question_mark_token().is_some() {
bail!("Promise constructor must have one required executor parameter");
}
let executor_type = executor
.type_annotation()
.context("Promise constructor executor is missing a type annotation")?
.ty()
.context("Promise constructor executor has a malformed type annotation")?;
let AnyTsType::TsFunctionType(executor) = executor_type else {
bail!("Promise constructor executor must be a function type");
};
if executor.type_parameters().is_some() {
bail!("Promise constructor executor must not be generic");
}
let executor_return_type = regular_return_type(executor.return_type()?, "Promise constructor")?;
if !matches!(executor_return_type, AnyTsType::TsVoidType(_)) {
bail!("Promise constructor executor must return void");
}
let return_type = memberView on GitHub (pinned to 3835945f06)
Solutions
- Rewrite the construct signature as `new <T>(executor: (resolve, reject) => void): Promise<T>;` with exactly one required parameter
- Remove any optional marker (`?`) from the executor parameter and delete extra parameters (resolve/reject belong inside the executor's function type, not the signature)
- Re-sync the bundled declaration from upstream lib.es2015.core.d.ts if it drifted
Example fix
// before new (executor?: (resolve, reject) => void): Promise<unknown>; // after new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void): Promise<T>;
Defensive patterns
Strategy: validation
Validate before calling
// Ensure exactly one required executor parameter
let sig = "new <T>(executor: (resolve, reject) => void): Promise<T>;";
assert!(!sig.contains("executor?"), "executor must be required"); Prevention
- Model the signature after lib.es2015.core.d.ts: one required executor parameter
- Put resolve/reject inside the executor function type, not as separate signature parameters
- Never mark the executor optional in ambient Promise declarations
When it happens
Trigger: Running global-types codegen against a declaration whose PromiseConstructor construct signature is `new ()`, `new (executor?, reject?)`, or has multiple parameters instead of exactly one required executor.
Common situations: Hand-editing the bundled Promise declaration and dropping the executor; copying a simplified/wrong signature from another lib definition; a parsing change shifting parameter counts.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- declare var Promise is missing a type annotation
- Promise global must include declare var Promise
- Promise constructor executor must be a function type
- Promise constructor executor must not be generic
- Promise constructor executor must return void
AI-assisted analysis of biomejs/biome@3835945f06 (2026-09-13).
Data as JSON: /api/errors/2aaacf9485d7b4e8.
Report an issue: GitHub.