biomejs/biome · error

value-side PromiseConstructor declarations are not supported

Error message

value-side PromiseConstructor declarations are not supported

What it means

During PromiseConstructor lowering, any value-side declaration (declare function, variable declarator, or import-equals) merged under the PromiseConstructor name causes this abort. The lowering logic expects PromiseConstructor to exist only as an interface declaration, since it synthesizes the constructor member itself from validated interface members.

Source

Thrown at xtask/codegen/src/generate_global_types/lower.rs:873

    let Some(constructor_group) = manifest.global_group("PromiseConstructor") else {
        bail!("Promise global value side references missing PromiseConstructor group");
    };
    if !constructor_group.has_role(GlobalDeclarationRole::Type) {
        bail!("PromiseConstructor must have a type-side declaration");
    }

    let mut saw_constructor_interface = false;
    let mut saw_construct_signature = false;
    for record in constructor_group.declarations() {
        match &record.kind {
            DeclarationKind::Interface => saw_constructor_interface = true,
            DeclarationKind::TypeAlias => {
                bail!("type aliases are not supported in PromiseConstructor")
            }
            DeclarationKind::DeclareFunction
            | DeclarationKind::VariableDeclarator { .. }
            | DeclarationKind::ImportEquals => {
                bail!("value-side PromiseConstructor declarations are not supported")
            }
        }

        let declaration = source_cache
            .find_interface_declaration(record)?
            .with_context(|| {
                format!(
                    "failed to find interface declaration {} at {:?}",
                    record.declared_name.text(),
                    record.text_range
                )
            })?;
        if declaration.extends_clause().is_some() {
            bail!("PromiseConstructor extends clauses are not supported");
        }
        if declaration.type_parameters().is_some() {
            bail!("PromiseConstructor type parameters are not supported");
        }

View on GitHub (pinned to 3835945f06)

Solutions

  1. Adjust the lib sources so PromiseConstructor has no value-side declarations (keep the value declaration separate, e.g. on `Promise`)
  2. Extend the PromiseConstructor lowering in lower.rs to handle the new declaration kind if it is intentional
  3. Pin the lib sources to a version matching the expected declaration shape

Example fix

// before (lib .d.ts)
declare function PromiseConstructor<T>(executor: ...): Promise<T>;
// after
interface PromiseConstructor { new <T>(...): Promise<T>; }
declare var Promise: PromiseConstructor;
Defensive patterns

Strategy: validation

Validate before calling

const VALUE_KINDS = ["DeclareFunction", "VariableDeclarator", "ImportEquals"];
const bad = group.declarations().filter(d => VALUE_KINDS.includes(d.kind));
if (bad.length) throw new Error("Value-side PromiseConstructor declarations present: " + bad.map(d => d.kind).join(", "));

Prevention

When it happens

Trigger: Running codegen with lib sources containing `declare var Promise: PromiseConstructor;` variants surfaced as a VariableDeclarator record, `declare function PromiseConstructor(...)`, or `import PromiseConstructor = ...` merged into the PromiseConstructor declaration group.

Common situations: TypeScript lib version updates that change how the Promise global value is declared; custom lib snapshots that add value-side declarations for the constructor type.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of biomejs/biome@3835945f06 (2026-09-13). Data as JSON: /api/errors/8bea62040d23d215. Report an issue: GitHub.