{"record":{"id":"a420d32aa156a090","repo":"biomejs/biome","slug":"promise-constructor-executor-must-return-void","errorCode":null,"errorMessage":"Promise constructor executor must return void","messagePattern":"Promise constructor executor must return void","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/codegen/src/generate_global_types/lower.rs","lineNumber":1110,"sourceCode":"        \"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\n        .type_annotation()\n        .context(\"Promise constructor is missing a return type\")?\n        .ty()\n        .context(\"Promise constructor has a malformed return type\")?;\n    validate_promise_reference(&return_type, \"Promise constructor\")\n}\n\n/// Requires `Promise<...>` without constraining the declaration's projected type argument.\nfn validate_promise_reference(type_node: &AnyTsType, owner: &str) -> Result<()> {\n    let AnyTsType::TsReferenceType(reference) = type_node else {\n        bail!(\"{owner} must return Promise\");\n    };\n    let name = reference\n        .name()\n        .with_context(|| format!(\"{owner} has a missing return type name\"))?;","sourceCodeStart":1092,"sourceCodeEnd":1128,"githubUrl":"https://github.com/biomejs/biome/blob/3835945f0638c88162351318b7bc8b64c5f2fba7/xtask/codegen/src/generate_global_types/lower.rs#L1092-L1128","documentation":"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.","triggerScenarios":"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.","commonSituations":"Hand-editing the executor and adding a return type; copying from a non-standard declaration file; an upstream change altering the executor signature.","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"],"exampleFix":"// before\nexecutor: (resolve, reject) => unknown\n// after\nexecutor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void","handlingStrategy":"validation","validationCode":"// Executor return type must be void\nlet executor = \"(resolve, reject) => void\";\nassert!(executor.trim_end().ends_with(\"=> void\"), \"executor must return void\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"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-14T05:17:10.506Z"}