typescript/unified-signatures Style
What it does
Disallow overload signatures that can be unified into one.
Why is this bad?
Duplicate overload signatures that only differ by a single type, or by an optional/rest parameter, are harder to maintain and read than a single unified signature.
Examples
Examples of incorrect code for this rule:
function f(a: number): void;
function f(a: string): void;Examples of correct code for this rule:
function f(a: number | string): void;Configuration
This rule accepts a configuration object with the following properties:
ignoreDifferentlyNamedParameters
type: boolean
default: false
Whether to ignore parameter name differences when comparing signatures. If false, signatures will not be considered unifiable if they have parameters in the same position with different names, even if the parameter types are the same.
ignoreOverloadsWithDifferentJSDoc
type: boolean
default: false
Whether to ignore JSDoc differences when comparing signatures. If false, signatures will not be considered unifiable if the closest leading block comments for the signatures are different, even if the signatures themselves are identical.
How to use
To enable this rule using the config file or in the CLI, you can use:
{
"rules": {
"typescript/unified-signatures": "error"
}
}oxlint --deny typescript/unified-signatures