biomejs/biome · error
Promise constructor executor must be a function type
Error message
Promise constructor executor must be a function type
What it means
The executor parameter of the Promise construct signature must itself be a TS function type (e.g. `(resolve, reject) => void`). Codegen bails if the executor's annotated type is anything else — a reference, union, or non-function type — because the lowering step needs to inspect the executor's parameters and return type to synthesize the constructor helper.
Source
Thrown at xtask/codegen/src/generate_global_types/lower.rs:1103
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 = 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.View on GitHub (pinned to 3835945f06)
Solutions
- Inline the executor as a direct function type: `executor: (resolve: ..., reject: ...) => void`
- If an alias is preferred, keep the function type inline in the validated declaration (aliases are not resolved by this validator)
- Check that the annotation parses as a TsFunctionType in the AST rather than a TsReferenceType
Example fix
// before new <T>(executor: Executor<T>): 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
// The executor must be an inline function type
let sig = "executor: (resolve: (v: T) => void, reject: (e?: unknown) => void) => void";
assert!(sig.starts_with("executor: ("), "executor must be an inline function type, not an alias"); Prevention
- Inline the executor's function type rather than referencing an alias
- Avoid unions or wrapper types on the executor annotation
- Verify AST shape (TsFunctionType) when changing how the executor is written
When it happens
Trigger: Running global-types codegen when the executor parameter is annotated as e.g. `Executor` (a type alias), `Function`, a union like `(resolve, reject) => void | undefined`, or any AnyTsType other than TsFunctionType.
Common situations: Replacing the inline executor function type with a named alias while refactoring the bundled declaration; upstream declarations using a different shape; a typo in the annotation.
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 not be generic
- Promise constructor executor must return void
AI-assisted analysis of biomejs/biome@3835945f06 (2026-09-13).
Data as JSON: /api/errors/3a03107f0c5853be.
Report an issue: GitHub.