Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 939d665

Browse files
authored
fix(eslint-plugin): [unified-signatures] allow overloads with different named and different number of parameters (typescript-eslint#6877)
1 parent ec24a92 commit 939d665

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/eslint-plugin/src/rules/unified-signatures.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,7 @@ export default util.createRule<Options, MessageIds>({
212212
const bTypeParams =
213213
b.typeParameters !== undefined ? b.typeParameters.params : undefined;
214214

215-
if (
216-
ignoreDifferentlyNamedParameters &&
217-
a.params.length === b.params.length
218-
) {
215+
if (ignoreDifferentlyNamedParameters) {
219216
for (let i = 0; i < a.params.length; i += 1) {
220217
if (
221218
a.params[i].type === b.params[i].type &&

packages/eslint-plugin/tests/rules/unified-signatures.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ function f(a: number | string): void {}
169169
},
170170
{
171171
code: `
172+
function f(m: number): void;
173+
function f(v: number, u: string): void;
174+
function f(v: number, u?: string): void {}
175+
`,
176+
options: [{ ignoreDifferentlyNamedParameters: true }],
177+
},
178+
{
179+
code: `
172180
function f(a: boolean, ...c: number[]): void;
173181
function f(a: boolean, ...d: string[]): void;
174182
function f(a: boolean, ...c: (number | string)[]): void {}

0 commit comments

Comments
 (0)