{"record":{"id":"d3fb62e321da1d5d","repo":"biomejs/biome","slug":"owner-must-return-promise","errorCode":null,"errorMessage":"{owner} must return Promise","messagePattern":"(.+?) must return Promise","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/codegen/src/generate_global_types/lower.rs","lineNumber":1124,"sourceCode":"        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\"))?;\n    let biome_js_syntax::AnyTsName::JsReferenceIdentifier(identifier) = name else {\n        bail!(\"{owner} must return Promise\");\n    };\n    if identifier.value_token()?.token_text_trimmed().text() != \"Promise\" {\n        bail!(\"{owner} must return Promise\");\n    }\n    let type_arguments = reference\n        .type_arguments()\n        .with_context(|| format!(\"{owner} must return Promise with one type argument\"))?;\n    let mut arguments = type_arguments.ts_type_argument_list().into_iter();\n    let Some(argument) = arguments.next() else {\n        bail!(\"{owner} must return Promise with one type argument\");\n    };\n    argument.with_context(|| format!(\"{owner} has a malformed Promise type argument\"))?;","sourceCodeStart":1106,"sourceCodeEnd":1142,"githubUrl":"https://github.com/biomejs/biome/blob/3835945f0638c88162351318b7bc8b64c5f2fba7/xtask/codegen/src/generate_global_types/lower.rs#L1106-L1142","documentation":"The construct signature (or a validated member's) return type must be a direct reference to `Promise`, not another type. This bail fires in `validate_promise_reference` when the return type node is not a TsReferenceType at all — e.g. a union, an intersection, a literal, or a mapped type. The owner name is interpolated into the message so the offending declaration is identifiable.","triggerScenarios":"Running global-types codegen when a validated declaration's return type is `PromiseLike<T> | Promise<T>`, `readonly Promise<T>`, `T`, or any non-reference type node instead of a plain `Promise<...>` reference.","commonSituations":"Editing the bundled global declarations and changing a return type to a union or alias; a parser change producing a different AnyTsType variant for what looks like a reference.","solutions":["Change the return type to a plain `Promise<T>` reference","Remove unions/intersections/modifiers around the return type","If a wrapper type is needed, validate it separately instead of routing it through validate_promise_reference"],"exampleFix":"// before\nnew <T>(executor: ...): Promise<T> | PromiseLike<T>;\n// after\nnew <T>(executor: ...): Promise<T>;","handlingStrategy":"validation","validationCode":"// Return type must be a plain reference, not a union/intersection/literal\nlet ret = \"Promise<T>\";\nassert!(!ret.contains('|') && !ret.contains('&'), \"return type must be a bare Promise reference\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep validated return types as bare `Promise<...>` references","Model nullable/alternative returns elsewhere, not in codegen-validated declarations","Check which validator a declaration routes through before changing its shape"],"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"}