{"record":{"id":"6396697742251e05","repo":"oxc-project/oxc","slug":"this-overload-can-be-combined-with-another-overloa-639669","errorCode":null,"errorMessage":"This overload can be combined with another overload into one signature with an optional parameter.","messagePattern":"This overload can be combined with another overload into one signature with an optional parameter\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/unified_signatures.rs","lineNumber":30,"sourceCode":"};\nuse oxc_diagnostics::{LabeledSpan, OxcDiagnostic};\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse rustc_hash::{FxHashMap, FxHashSet};\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn unified_signatures_diagnostic<L: Into<LabeledSpan>, T: IntoIterator<Item = L>>(\n    message: String,\n    labels: T,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(message).with_labels(labels)\n}\n\n#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema)]\n#[serde(default, rename_all = \"camelCase\", deny_unknown_fields)]\npub struct UnifiedSignaturesOptions {\n    /// Whether to ignore parameter name differences when comparing signatures. If `false`, signatures\n    /// will not be considered unifiable if they have parameters in the same position with different\n    /// names, even if the parameter types are the same.\n    ignore_differently_named_parameters: bool,\n    /// Whether to ignore JSDoc differences when comparing signatures. If `false`, signatures will not\n    /// be considered unifiable if the closest leading block comments for the signatures are different,\n    /// even if the signatures themselves are identical.\n    #[serde(rename = \"ignoreOverloadsWithDifferentJSDoc\")]\n    ignore_overloads_with_different_jsdoc: bool,\n}\n\n#[derive(Debug, Default, Clone, Deserialize, Serialize)]\npub struct UnifiedSignatures(UnifiedSignaturesOptions);","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/unified_signatures.rs#L12-L48","documentation":"Diagnostic from oxlint's `typescript/unified-signatures` rule, optional-parameter variant with singular wording: the overload group contains more than two signatures, so oxlint points at one overload that can be combined with another whose extra trailing parameter is a plain parameter that could simply be optional. The comparison logic requires identical parameter types on the shared prefix and omittable parameters beyond the divergence point.","triggerScenarios":"Three or more same-named signatures where two of them share identical parameter types up to a prefix and one adds only a trailing non-rest parameter (required or optional), while the shorter of the pair does not itself end in a rest parameter.","commonSituations":"Large overload families for config-driven APIs where an options argument was bolted on via extra overloads; interface declarations merged from multiple modules; lint cleanups after enabling stricter TypeScript linting presets.","solutions":["Replace the flagged pair with a single signature using an optional parameter (`param?: T`).","If each overload documents a distinct case in JSDoc, set `ignoreOverloadsWithDifferentJSDoc: true` before re-running.","Set `ignoreDifferentlyNamedParameters: true` if parameter naming is the only intentional difference.","Disable the rule for that declaration file via an inline comment or override."],"exampleFix":"// before\ndeclare function query<T>(sql: string): Promise<T>;\ndeclare function query<T>(sql: string, params: unknown[]): Promise<T>;\ndeclare function query<T>(sql: string, opts: QueryOptions): Promise<T>;\n// after\ndeclare function query<T>(sql: string, params?: unknown[]): Promise<T>;\ndeclare function query<T>(sql: string, opts: QueryOptions): Promise<T>;","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Model growing option sets with a single options-object parameter rather than extra overloads.","When an overload family exceeds two entries, check each pair for collapsible optional-parameter differences.","Add oxlint to pre-commit hooks so unifiable overloads never reach the main branch."],"tags":["oxlint","lint","typescript","overloads","optional-parameters","style"],"backgroundTag":"typescript-overload-unification","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}