{"record":{"id":"4d9fa26daeaaa92e","repo":"biomejs/biome","slug":"must-not-be-optional","errorCode":null,"errorMessage":"{} must not be optional","messagePattern":"(.+?) must not be optional","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/codegen/src/generate_global_types/lower.rs","lineNumber":1005,"sourceCode":"            | AnyTsTypeMember::TsCallSignatureTypeMember(_)\n            | AnyTsTypeMember::TsConstructSignatureTypeMember(_)\n            | AnyTsTypeMember::TsIndexSignatureTypeMember(_) => {}\n        }\n    }\n    Ok(())\n}\n\n/// Marks a selected method after checking the Promise return retained by the projection.\nfn validate_selected_promise_method(\n    method: &TsMethodSignatureTypeMember,\n    location: PromiseMemberLocation,\n    saw_methods: &mut [bool; PROMISE_METHOD_COUNT],\n) -> Result<()> {\n    let Some((index, specification)) = selected_promise_method(method.name()?, location)? else {\n        return Ok(());\n    };\n    if method.optional_token().is_some() {\n        bail!(\"{} must not be optional\", specification.global_name);\n    }\n    let return_type = method\n        .return_type_annotation()\n        .with_context(|| format!(\"{} is missing a return type\", specification.global_name))?\n        .ty()\n        .with_context(|| format!(\"{} has a malformed return type\", specification.global_name))?;\n    let return_type = regular_return_type(return_type, specification.global_name)?;\n    validate_promise_reference(&return_type, specification.global_name)?;\n    saw_methods[index] = true;\n    Ok(())\n}\n\n/// Resolves a literal member name only within its instance or static declaration side.\nfn selected_promise_method(\n    name: AnyJsObjectMemberName,\n    location: PromiseMemberLocation,\n) -> Result<Option<(usize, PromiseMethodSpecification)>> {\n    let AnyJsObjectMemberName::JsLiteralMemberName(name) = name else {","sourceCodeStart":987,"sourceCodeEnd":1023,"githubUrl":"https://github.com/biomejs/biome/blob/3835945f0638c88162351318b7bc8b64c5f2fba7/xtask/codegen/src/generate_global_types/lower.rs#L987-L1023","documentation":"validate_promise_methods checks each selected Promise method (matched by name and location against PROMISE_METHOD_SPECIFICATIONS). If a matching method carries an `?` optional token, the lowering rejects it because required members are assumed non-optional; the error names the method via specification.global_name.","triggerScenarios":"Running generate_global_types when a required Promise method is declared optional in the lib sources, e.g. `finally?: (...) => Promise<T>;` or an optional method signature.","commonSituations":"Hand-edited snapshots marking methods optional for stricter consumer checks; tooling that converts method signatures to optional properties.","solutions":["Remove the `?` optional token from the method declaration in the lib sources","Relax the optional check in lower.rs if optionality is now acceptable","Regenerate the snapshot from upstream lib.d.ts where the method is required"],"exampleFix":"// before\ninterface Promise<T> { finally?(onfinally: () => void): Promise<T>; }\n// after\ninterface Promise<T> { finally(onfinally: () => void): Promise<T>; }","handlingStrategy":"validation","validationCode":"for (const m of promiseDecl.members) {\n  if (m.optional && REQUIRED_METHODS.includes(m.name)) {\n    throw new Error(`Required Promise method '${m.name}' must not be optional`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never mark required Promise methods with `?` in snapshots","Reject optional tokens on known-good method names in a pre-codegen lint","Regenerate snapshots from upstream sources instead of hand edits"],"tags":["codegen","build-time","optionality"],"backgroundTag":"schema-validation-failed","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"}