{"record":{"id":"0f1ce87fd133a5cd","repo":"oxc-project/oxc","slug":"these-overloads-can-be-combined-into-one-signature-0f1ce8","errorCode":null,"errorMessage":"These overloads can be combined into one signature with a rest parameter.","messagePattern":"These overloads can be combined into one signature with a rest 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 (port of @typescript-eslint/unified-signatures). It fires only on TypeScript files and reports when a group of exactly two overload signatures can be merged into one: their parameters are identical up to the common prefix and the longer signature simply adds a trailing rest parameter, so the longer signature already accepts every call the pair accepted. The rule scans top-level function overloads, TS module blocks, interface bodies, type-literal members, and class method overloads.","triggerScenarios":"A .ts/.d.ts file containing two same-named signatures where the shorter does not end in a rest parameter and the longer adds only `...rest`, e.g. `declare function log(msg: string): void;` next to `declare function log(msg: string, ...meta: unknown[]): void;`. Equivalent method pairs in interfaces, type literals, and class overload sets are also scanned.","commonSituations":"Hand-maintained overload lists for logging, fetch wrappers, or query builders; declaration files where overloads accreted over years; teams enabling the `typescript` oxlint preset or migrating from typescript-eslint where this rule was already active.","solutions":["Delete the shorter overload and keep the single signature that already includes the rest parameter.","If the split is intentional because each overload has different JSDoc, enable the `ignoreOverloadsWithDifferentJSDoc` option in .oxlintrc.json.","If the overloads deliberately differ only by parameter names, enable `ignoreDifferentlyNamedParameters`.","Suppress the single intentional case with an inline disable comment for `typescript/unified-signatures`."],"exampleFix":"// before\ndeclare function log(msg: string): void;\ndeclare function log(msg: string, ...meta: unknown[]): void;\n// after\ndeclare function log(msg: string, ...meta: unknown[]): void;","handlingStrategy":"validation","validationCode":"// .oxlintrc.json — configure before enabling, so intentional splits do not fail CI\n{\n  \"rules\": {\n    \"typescript/unified-signatures\": [\n      \"warn\",\n      { \"ignoreDifferentlyNamedParameters\": true, \"ignoreOverloadsWithDifferentJSDoc\": true }\n    ]\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer one signature with union types (`a: number | string`) or rest/optional parameters over near-duplicate overloads.","Review overload lists in .d.ts files during code review — unifiable pairs usually accrete there.","If each overload carries distinct JSDoc by design, set `ignoreOverloadsWithDifferentJSDoc` before enabling the rule."],"tags":["oxlint","lint","typescript","overloads","rest-parameter","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"}