overloadSignaturesAdjacent
Require that function overload signatures be consecutive.
✅ This rule is included in the ts stylistic presets.
Function overload signatures represent multiple ways a function can be called with different parameter types or return types. When overload signatures are separated by other code, it becomes harder to see the full API of a function at a glance. Grouping all overload signatures for a function together makes code easier to read and understand.
This rule reports when a function’s overload signatures are not adjacent to each other.
Examples
Section titled “Examples”function f(x: number): void;function other(): void {}function f(x: string): void;function f(x: number | string): void {}interface I { method(x: number): void; other(): void; method(x: string): void; method(x: number | string): void;}function f(x: number): void;function f(x: string): void;function f(x: number | string): void {}interface I { method(x: number): void; method(x: string): void; method(x: number | string): void;}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”It can sometimes be useful to place overload signatures alongside other meaningful parts of a type. For example, if each overload corresponds to a different property, you might wish to place each overload next to its property. You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.