{"record":{"id":"36ebc0a8677850f4","repo":"biomejs/biome","slug":"declare-var-promise-is-missing-a-type-annotation","errorCode":null,"errorMessage":"declare var Promise is missing a type annotation","messagePattern":"declare var Promise is missing a type annotation","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/codegen/src/generate_global_types/lower.rs","lineNumber":1069,"sourceCode":") -> Result<()> {\n    let mut saw_value = false;\n    for record in records {\n        let DeclarationKind::VariableDeclarator { .. } = &record.kind else {\n            continue;\n        };\n        let declarator = source_cache\n            .find_variable_declarator(record)?\n            .with_context(|| {\n                format!(\n                    \"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","sourceCodeStart":1051,"sourceCodeEnd":1087,"githubUrl":"https://github.com/biomejs/biome/blob/3835945f0638c88162351318b7bc8b64c5f2fba7/xtask/codegen/src/generate_global_types/lower.rs#L1051-L1087","documentation":"This error comes from Biome's xtask codegen, not the runtime library. While lowering the bundled TypeScript global declarations, the tool found a `declare var Promise` whose declarator lacks a `: T` type annotation, which is required to extract and validate the `PromiseConstructor` shape. The build aborts so a malformed ambient Promise declaration never reaches generated code.","triggerScenarios":"Running the global-types codegen (e.g. `cargo codegen global-types` or a full `just gen`) when the source `.d.ts`-style declaration processed by generate_global_types defines `declare var Promise` without a type annotation, or the lowering logic fails to parse the annotation into a TsTypeAnnotation.","commonSituations":"Editing or vendoring Biome's bundled global declaration file by hand and writing `declare var Promise;` instead of `declare var Promise: PromiseConstructor;`; a parser/AST change making variable_annotation() return None; upgrading the declaration source that dropped the annotation.","solutions":["Restore the type annotation on the ambient Promise variable: `declare var Promise: PromiseConstructor;`","If the declaration source is generated/vendored, regenerate or re-sync it from upstream instead of editing by hand","If an AST change broke `variable_annotation()`, update lower.rs to read the annotation via the new API"],"exampleFix":"// before\ndeclare var Promise;\n// after\ndeclare var Promise: PromiseConstructor;","handlingStrategy":"validation","validationCode":"// Before running codegen, verify the ambient Promise var carries an annotation\nlet decl = \"declare var Promise: PromiseConstructor;\";\nassert!(decl.contains(\":\"), \"declare var Promise needs a type annotation\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write ambient values with explicit type annotations: `declare var X: XConstructor;`","Never hand-edit the bundled global declaration files; regenerate from upstream","Run the global-types codegen early in CI to catch declaration drift before merging"],"tags":["rust","codegen","typescript","build-time","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"}