biomejs/biome · error
Promise constructor executor must not be generic
Error message
Promise constructor executor must not be generic
What it means
The executor function type must not declare its own type parameters. A generic executor like `<T>(resolve, reject) => void` cannot be modeled by the synthetic constructor helper, so codegen bails. The generic Promise parameter belongs on the construct signature, not on the executor.
Source
Thrown at xtask/codegen/src/generate_global_types/lower.rs:1106
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 = 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");View on GitHub (pinned to 3835945f06)
Solutions
- Remove the type-parameter list from the executor function type, leaving `executor: (resolve, reject) => void`
- Keep the `<T>` generic parameter on the construct signature itself, where it belongs
- Re-sync the bundled declaration if the drift came from upstream
Example fix
// before new <T>(executor: <T>(resolve, reject) => void): Promise<T>; // after new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void): Promise<T>;
Defensive patterns
Strategy: validation
Validate before calling
// Executor must not declare its own type parameters
let executor = "(resolve: (v: T) => void, reject: (e?: unknown) => void) => void";
assert!(!executor.starts_with("<"), "executor must not be generic"); Prevention
- Keep generics on the construct signature, never on the executor function type
- When copying signatures from other libraries, strip executor-level type parameters
- Review merges of upstream declaration changes for accidental generic additions
When it happens
Trigger: Running global-types codegen when the bundled declaration writes the executor as a generic function type, e.g. `new <T>(executor: <T>(resolve, reject) => void): Promise<T>`.
Common situations: Copy-pasting a signature from another library where the executor was generic; an over-eager edit adding `<T>` to the executor; merging upstream changes incorrectly.
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
- {owner} must return Promise with one type argument
- 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
AI-assisted analysis of biomejs/biome@3835945f06 (2026-09-13).
Data as JSON: /api/errors/0c290748ef638b9e.
Report an issue: GitHub.