biomejs/biome · error
Promise constructor executor must return void
Error message
Promise constructor executor must return void
What it means
After validating the executor, codegen requires the executor function type's return type to be `void`. An executor returning anything else (e.g. `boolean`, `unknown`, `Promise<void>`) does not match the ECMAScript contract, so the tool bails. This keeps the synthetic constructor helper aligned with the real Promise semantics.
Source
Thrown at xtask/codegen/src/generate_global_types/lower.rs:1110
"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 = member
.type_annotation()
.context("Promise constructor is missing a return type")?
.ty()
.context("Promise constructor has a malformed return type")?;
validate_promise_reference(&return_type, "Promise constructor")
}
/// Requires `Promise<...>` without constraining the declaration's projected type argument.
fn validate_promise_reference(type_node: &AnyTsType, owner: &str) -> Result<()> {
let AnyTsType::TsReferenceType(reference) = type_node else {
bail!("{owner} must return Promise");
};
let name = reference
.name()
.with_context(|| format!("{owner} has a missing return type name"))?;View on GitHub (pinned to 3835945f06)
Solutions
- Change the executor's return type to `void` in the construct signature
- Remove any accidental return-type annotation if void was intended
- Re-sync the bundled declaration from upstream lib definitions
Example fix
// before executor: (resolve, reject) => unknown // after executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void
Defensive patterns
Strategy: validation
Validate before calling
// Executor return type must be void
let executor = "(resolve, reject) => void";
assert!(executor.trim_end().ends_with("=> void"), "executor must return void"); Prevention
- Always end the executor function type with `=> void`
- Do not add return types (unknown, boolean, Promise<void>) to the executor
- Diff declaration edits against upstream lib definitions before committing
When it happens
Trigger: Running global-types codegen when the bundled Promise declaration annotates the executor with a return type other than void, such as `=> unknown` or a type alias that resolves to a non-void type node.
Common situations: Hand-editing the executor and adding a return type; copying from a non-standard declaration file; an upstream change altering the executor signature.
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 must have one required executor paramete
- Promise constructor executor must be a function type
- Promise constructor executor must not be generic
AI-assisted analysis of biomejs/biome@3835945f06 (2026-09-13).
Data as JSON: /api/errors/a420d32aa156a090.
Report an issue: GitHub.