{"record":{"id":"2aaacf9485d7b4e8","repo":"biomejs/biome","slug":"promise-constructor-must-have-one-required-executor","errorCode":null,"errorMessage":"Promise constructor must have one required executor parameter","messagePattern":"Promise constructor must have one required executor parameter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/codegen/src/generate_global_types/lower.rs","lineNumber":1095,"sourceCode":"    }\n    if !saw_value {\n        bail!(\"Promise global must include declare var Promise\");\n    }\n    Ok(())\n}\n\n/// Requires the executor and return shapes represented by the synthetic constructor helper.\nfn validate_promise_construct_signature(member: &TsConstructSignatureTypeMember) -> Result<()> {\n    single_type_parameter_name(member.type_parameters(), \"Promise constructor\")?;\n\n    let mut parameters = member.parameters()?.items().into_iter();\n    let executor = required_formal_parameter(\n        parameters.next(),\n        \"Promise constructor\",\n        \"one executor parameter\",\n    )?;\n    if parameters.next().is_some() || executor.question_mark_token().is_some() {\n        bail!(\"Promise constructor must have one required executor parameter\");\n    }\n    let executor_type = executor\n        .type_annotation()\n        .context(\"Promise constructor executor is missing a type annotation\")?\n        .ty()\n        .context(\"Promise constructor executor has a malformed type annotation\")?;\n    let AnyTsType::TsFunctionType(executor) = executor_type else {\n        bail!(\"Promise constructor executor must be a function type\");\n    };\n    if executor.type_parameters().is_some() {\n        bail!(\"Promise constructor executor must not be generic\");\n    }\n    let executor_return_type = regular_return_type(executor.return_type()?, \"Promise constructor\")?;\n    if !matches!(executor_return_type, AnyTsType::TsVoidType(_)) {\n        bail!(\"Promise constructor executor must return void\");\n    }\n\n    let return_type = member","sourceCodeStart":1077,"sourceCodeEnd":1113,"githubUrl":"https://github.com/biomejs/biome/blob/3835945f0638c88162351318b7bc8b64c5f2fba7/xtask/codegen/src/generate_global_types/lower.rs#L1077-L1113","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nnew (executor?: (resolve, reject) => void): Promise<unknown>;\n// after\nnew <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void): Promise<T>;","handlingStrategy":"validation","validationCode":"// Ensure exactly one required executor parameter\nlet sig = \"new <T>(executor: (resolve, reject) => void): Promise<T>;\";\nassert!(!sig.contains(\"executor?\"), \"executor must be required\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","codegen","typescript","globals"],"backgroundTag":"internal-invariant-violation","analyzedSha":"3835945f0638c88162351318b7bc8b64c5f2fba7","analyzedAt":"2026-09-13T15:11:16.919Z","contentChangedAt":"2026-09-13T15:11:16.919Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}