{"record":{"id":"73b6bb6e1adf76cc","repo":"biomejs/biome","slug":"promise-global-must-include-declare-var-promise","errorCode":null,"errorMessage":"Promise global must include declare var Promise","messagePattern":"Promise global must include declare var Promise","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/codegen/src/generate_global_types/lower.rs","lineNumber":1079,"sourceCode":"                    \"failed to find variable declaration {} at {:?}\",\n                    record.declared_name.text(),\n                    record.text_range\n                )\n            })?;\n        let Some(AnyTsVariableAnnotation::TsTypeAnnotation(annotation)) =\n            declarator.variable_annotation()\n        else {\n            bail!(\"declare var Promise is missing a type annotation\");\n        };\n        validate_reference_type(\n            &annotation.ty()?,\n            \"PromiseConstructor\",\n            \"declare var Promise\",\n        )?;\n        saw_value = true;\n    }\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","sourceCodeStart":1061,"sourceCodeEnd":1097,"githubUrl":"https://github.com/biomejs/biome/blob/3835945f0638c88162351318b7bc8b64c5f2fba7/xtask/codegen/src/generate_global_types/lower.rs#L1061-L1097","documentation":"The global-types lowering step validates that the Promise global section contains at least one value declaration. If, after processing all members, no `declare var Promise` was seen (only type-side members like interfaces or a bare namespace), the tool bails because the constructor value itself is missing. This guarantees generated code models the Promise constructor value, not just its types.","triggerScenarios":"Running the global-types codegen when the Promise global block's declarations were removed, renamed (e.g. `declare var PromiseLike` only), or failed the earlier annotation check so `saw_value` was never set to true.","commonSituations":"Accidentally deleting the `declare var Promise` line while editing the bundled .d.ts source; refactoring the lowering loop so the Promise variable no longer matches; upstream declaration changes removing the var.","solutions":["Re-add the ambient value: `declare var Promise: PromiseConstructor;` in the global declaration section","Verify the lowering loop actually visits the variable declarator and sets saw_value (check that the member kind matches what lower.rs matches on)","Regenerate/sync the bundled global declarations if they were hand-edited"],"exampleFix":"// before\ndeclare interface PromiseConstructor { /* ... */ }\n// after\ndeclare interface PromiseConstructor { /* ... */ }\ndeclare var Promise: PromiseConstructor;","handlingStrategy":"validation","validationCode":"// Check the Promise global block contains the constructor value\nlet src = std::fs::read_to_string(\"globals.d.ts\")?;\nassert!(src.contains(\"declare var Promise\"), \"Promise global block must declare the var\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep `declare var Promise: PromiseConstructor;` adjacent to the PromiseConstructor interface","After editing declarations, grep for `declare var Promise` before running codegen","Treat removal of ambient vars as a breaking declaration change requiring codegen review"],"tags":["rust","codegen","typescript","globals","build-time"],"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"}