{"record":{"id":"fc056bf5c7216de7","repo":"biomejs/biome","slug":"owner-must-return-promise-with-one-type-argument","errorCode":null,"errorMessage":"{owner} must return Promise with one type argument","messagePattern":"(.+?) must return Promise with one type argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/codegen/src/generate_global_types/lower.rs","lineNumber":1140,"sourceCode":"fn 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\"))?;\n    if arguments.next().is_some() {\n        bail!(\"{owner} must return Promise with one type argument\");\n    }\n    Ok(())\n}\n\n/// Preserves whether lookup reaches the helper through an instance or the constructor.\nfn promise_member(specification: PromiseMethodSpecification) -> LoweredTypeMember {\n    let kind = match specification.location {\n        PromiseMemberLocation::Instance => LoweredMemberKind::Named { optional: false },\n        PromiseMemberLocation::Static => LoweredMemberKind::NamedStatic,\n    };\n    LoweredTypeMember {\n        name: Text::from(specification.source_name),\n        kind,\n        type_reference: LoweredTypeReference::Predefined(specification.member_type_id),","sourceCodeStart":1122,"sourceCodeEnd":1158,"githubUrl":"https://github.com/biomejs/biome/blob/3835945f0638c88162351318b7bc8b64c5f2fba7/xtask/codegen/src/generate_global_types/lower.rs#L1122-L1158","documentation":"The final Promise-reference check requires exactly one type argument. This bail fires in two cases: the argument list is empty (no first argument), or there is more than one argument (e.g. `Promise<T, U>`). Errors in the single argument itself are reported separately as 'malformed Promise type argument'.","triggerScenarios":"Running global-types codegen when a validated declaration returns `Promise<>`, `Promise<T, U>`, or `Promise<T, PromiseError>` — i.e. zero or 2+ type arguments.","commonSituations":"Porting a Promise-like type from another language/library with two parameters; typos adding a stray second argument; an empty argument list left after deleting a parameter.","solutions":["Keep exactly one type argument: `Promise<T>`","Remove any extra type arguments beyond the first","Ensure the argument list is non-empty (never `Promise<>`)"],"exampleFix":"// before\nnew <T>(executor: ...): Promise<T, U>;\n// after\nnew <T>(executor: ...): Promise<T>;","handlingStrategy":"validation","validationCode":"// Exactly one type argument required\nlet args = count_type_args(\"Promise<T>\");\nassert_eq!(args, 1, \"Promise must have exactly one type argument\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep Promise monomorphic in declarations: one type parameter only","Remove extra parameters when porting multi-parameter Promise-like types","Validate declaration shape with codegen locally before opening a PR"],"tags":["rust","codegen","typescript","generics","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"}