src/content/docs/linter/rules/use-adjacent-overload-signatures.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.9.0` - Diagnostic Category: [`lint/suspicious/useAdjacentOverloadSignatures`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). - Sources: - Same as [`@typescript-eslint/adjacent-overload-signatures`](https://typescript-eslint.io/rules/adjacent-overload-signatures){
"linter": {
"rules": {
"suspicious": {
"useAdjacentOverloadSignatures": "error"
}
}
}
}
Disallow the use of overload signatures that are not next to each other.
Overload signatures must be adjacent. If a key is defined multiple times, only the last definition takes effect. Previous definitions are ignored. This rule is useful for preventing accidental overloads that are not adjacent. It is recommended to keep the overload signatures adjacent to make the code easier to read and maintain.
type Foo = {
foo_type(s: string): void;
foo_type(n: number): void;
bar_type(): void;
foo_type(sn: string | number): void;
};
interface Foo {
foo_interface(s: string): void;
foo_interface(n: number): void;
bar_interface(): void;
foo_interface(sn: string | number): void;
}
class A {
fooA(s: string): void;
fooA(n: number): void;
barA(): void {};
fooA(sn: string | number): void {};
}
declare namespace Foo {
export function foo_declare(s: string): void;
export function foo_declare(n: number): void;
export function foo_declare(sn: string | number): void;
export function bar_declare(): void;
}
type Foo = {
foo_type(s: string): void;
foo_type(n: number): void;
foo_type(sn: string | number): void;
bar_type(): void;
};
interface Foo {
foo_interface(s: string): void;
foo_interface(n: number): void;
foo_interface(sn: string | number): void;
bar_interface(): void;
}
class A {
fooA(s: string): void;
fooA(n: number): void;
fooA(sn: string | number): void {}
barA(): void {}
}