Urara-Blog/node_modules/.pnpm-store/v3/files/11/0c1302400d6c9aa63be6152a0ff9c92f808d807ff7999bc0f8e84f0da26ef1c1b293e95ce3e8c3eb16df4c54f109f55418fc738efcec0a604d86c36bbe8d63
2022-08-14 01:14:53 +08:00

106 lines
2.1 KiB
Text

---
description: 'Require that member overloads be consecutive.'
---
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/adjacent-overload-signatures** for documentation.
Grouping overloaded members together can improve readability of the code.
## Rule Details
This rule aims to standardize the way overloaded members are organized.
<!--tabs-->
### ❌ Incorrect
```ts
declare namespace Foo {
export function foo(s: string): void;
export function foo(n: number): void;
export function bar(): void;
export function foo(sn: string | number): void;
}
type Foo = {
foo(s: string): void;
foo(n: number): void;
bar(): void;
foo(sn: string | number): void;
};
interface Foo {
foo(s: string): void;
foo(n: number): void;
bar(): void;
foo(sn: string | number): void;
}
class Foo {
foo(s: string): void;
foo(n: number): void;
bar(): void {}
foo(sn: string | number): void {}
}
export function foo(s: string): void;
export function foo(n: number): void;
export function bar(): void;
export function foo(sn: string | number): void;
```
### ✅ Correct
```ts
declare namespace Foo {
export function foo(s: string): void;
export function foo(n: number): void;
export function foo(sn: string | number): void;
export function bar(): void;
}
type Foo = {
foo(s: string): void;
foo(n: number): void;
foo(sn: string | number): void;
bar(): void;
};
interface Foo {
foo(s: string): void;
foo(n: number): void;
foo(sn: string | number): void;
bar(): void;
}
class Foo {
foo(s: string): void;
foo(n: number): void;
foo(sn: string | number): void {}
bar(): void {}
}
export function bar(): void;
export function foo(s: string): void;
export function foo(n: number): void;
export function foo(sn: string | number): void;
```
## Options
```jsonc
// .eslintrc.json
{
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error"
}
}
```
This rule is not configurable.
## When Not To Use It
If you don't care about the general structure of the code, then you will not need this rule.