Skip to content

Commit

Permalink
fix(check-param-names, require-param): handle ts constructor as arg; f…
Browse files Browse the repository at this point in the history
…ixes #576
  • Loading branch information
Eric Hacke authored Jun 14, 2020
1 parent f29f9e2 commit bd11a73
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2210,6 +2210,17 @@ export default function (input: {
}): void {
input;
}

export class Thing {
foo: any;

/**
* @param {} C
*/
constructor(C: { new (): any }) {
this.foo = new C();
}
}
````


Expand Down
2 changes: 1 addition & 1 deletion src/jsdocUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const flattenRoots = (params, root = '') => {

type T = string | [?string, T];
const getPropertiesFromPropertySignature = (propSignature): T => {
if (propSignature.type === 'TSIndexSignature') {
if (propSignature.type === 'TSIndexSignature' || propSignature.type === 'TSConstructSignatureDeclaration') {
return undefined;
}
if (propSignature.typeAnnotation && propSignature.typeAnnotation.typeAnnotation.type === 'TSTypeLiteral') {
Expand Down
15 changes: 15 additions & 0 deletions test/rules/assertions/checkParamNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -1125,5 +1125,20 @@ export default {
`,
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
export class Thing {
foo: any;
/**
* @param {} C
*/
constructor(C: { new (): any }) {
this.foo = new C();
}
}
`,
parser: require.resolve('@typescript-eslint/parser'),
},
],
};

0 comments on commit bd11a73

Please sign in to comment.