Skip to content

Commit

Permalink
fix(eslint-plugin): [unified-signatures] allow overloads with differe…
Browse files Browse the repository at this point in the history
…nt named and different number of parameters (#6877)
  • Loading branch information
NotWoods committed Apr 10, 2023
1 parent ec24a92 commit 939d665
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 1 addition & 4 deletions packages/eslint-plugin/src/rules/unified-signatures.ts
Expand Up @@ -212,10 +212,7 @@ export default util.createRule<Options, MessageIds>({
const bTypeParams =
b.typeParameters !== undefined ? b.typeParameters.params : undefined;

if (
ignoreDifferentlyNamedParameters &&
a.params.length === b.params.length
) {
if (ignoreDifferentlyNamedParameters) {
for (let i = 0; i < a.params.length; i += 1) {
if (
a.params[i].type === b.params[i].type &&
Expand Down
8 changes: 8 additions & 0 deletions packages/eslint-plugin/tests/rules/unified-signatures.test.ts
Expand Up @@ -169,6 +169,14 @@ function f(a: number | string): void {}
},
{
code: `
function f(m: number): void;
function f(v: number, u: string): void;
function f(v: number, u?: string): void {}
`,
options: [{ ignoreDifferentlyNamedParameters: true }],
},
{
code: `
function f(a: boolean, ...c: number[]): void;
function f(a: boolean, ...d: string[]): void;
function f(a: boolean, ...c: (number | string)[]): void {}
Expand Down

0 comments on commit 939d665

Please sign in to comment.