Skip to content

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.

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;
}

This rule is not configurable.

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.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.