oxc-project/oxc · warning · OxcDiagnostic
All {fn_name:?} signatures should be adjacent.
Error message
All {fn_name:?} signatures should be adjacent. What it means
Diagnostic from the typescript `adjacent-overload-signatures` rule in oxlint. It fires when overloads of the same function or method are separated by other members (or statements), e.g. one `foo` signature, then `bar`, then another `foo` signature. Split overloads are easy to miss when reading and historically caused issues for some language-service consumers.
Source
Thrown at crates/oxc_linter/src/rules/typescript/adjacent_overload_signatures.rs:24
},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use oxc_str::CompactStr;
use crate::{
AstNode,
context::{ContextHost, LintContext},
rule::Rule,
};
fn adjacent_overload_signatures_diagnostic(
fn_name: &str,
first: Option<Span>,
second: Span,
) -> OxcDiagnostic {
let mut d = OxcDiagnostic::warn(format!("All {fn_name:?} signatures should be adjacent."))
.with_help(format!("Move all {fn_name:?} overload signatures together, placing them consecutively before any other members."))
.with_note("Function overload signatures represent multiple ways a function can be called. Keeping them adjacent makes it easier for developers to understand all available call signatures at a glance.");
if let Some(span) = first {
d = d.and_label(span);
}
d.and_label(second)
}
#[derive(Debug, Default, Clone)]
pub struct AdjacentOverloadSignatures;
declare_oxc_lint!(
/// ### What it does
///
/// Require that function overload signatures be consecutive.
///
/// ### Why is this bad?
///View on GitHub (pinned to e1e7af627c)
Solutions
- Move the stray overload next to its siblings, keeping all consecutive signatures before the implementation.
- Sort/generate members deterministically (e.g. by name) in generated files so same-name signatures cluster.
- In editors, use symbol search on the method name to find all signatures and gather them; then re-run oxlint to confirm the diagnostic clears.
Example fix
// before
class Foo {
bar(): void;
foo(x: string): string;
baz(): void;
foo(x: number): number;
}
// after
class Foo {
bar(): void;
baz(): void;
foo(x: string): string;
foo(x: number): number;
} Defensive patterns
Strategy: validation
Validate before calling
// report overload names that appear in non-adjacent member groups
function nonAdjacentOverloads(members: { name: string }[][]): Set<string> {
const seen = new Map<string, number>();
const bad = new Set<string>();
let last = -1;
for (const group of members.flat()) { /* pair with your AST walker */ }
return bad;
}
// simplest: rely on oxlint -p 'class $C { $$$A; $$$B; $$$C; }' or run `oxlint --ts` in CI Prevention
- Add new overloads directly beneath existing ones for the same method; use editor symbol search to find them all.
- Keep interfaces/classes sorted by member name in generated code so same-name signatures cluster.
- Run oxlint with the typescript plugin in pre-commit to catch interleaved overloads before review.
When it happens
Trigger: The rule scans class/object/export declarations and statement lists; when two signature groups with the same name (fn_name) are non-adjacent, it reports 'All "foo" signatures should be adjacent.' with labels on the first and second spans. Examples: `class C { foo(): void; bar(): number; foo(x: number): number; }`, or overload declarations in a file separated by other statements or imports.
Common situations: Merge conflicts and copy-paste reordering inside interfaces/classes; generated `.d.ts`-style files that interleave members alphabetically; adding an overload at the bottom of a class far from its siblings.
Related errors
- These overloads can be combined into one signature with a re
- This overload can be combined with another overload into one
- These overloads can be combined into one signature with an o
- This overload can be combined with another overload into one
- encountered allocation error
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/6873b164c50f9388.
Report an issue: GitHub.