Skip to content

Commit

Permalink
fix(check-param-names): avoid erring upon `TSCallSignatureDeclarati…
Browse files Browse the repository at this point in the history
…on`; fixes #624
  • Loading branch information
brettz9 committed Aug 17, 2020
1 parent c140060 commit 8341f97
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -2383,6 +2383,17 @@ function quux (foo, {bar}) {

}
// Options: [{"checkDestructured":false}]

class A {
/**
* Show a prompt.
* @param hideButton true if button should be hidden, false otherwise
* @param onHidden delegate to call when the prompt is hidden
*/
public async showPrompt(hideButton: boolean, onHidden: {(): void}): Promise<void>
{
}
}
````


Expand Down
6 changes: 5 additions & 1 deletion src/jsdocUtils.js
Expand Up @@ -80,7 +80,11 @@ const flattenRoots = (params, root = '') => {

type T = string | [?string, T];
const getPropertiesFromPropertySignature = (propSignature): T => {
if (propSignature.type === 'TSIndexSignature' || propSignature.type === 'TSConstructSignatureDeclaration') {
if (
propSignature.type === 'TSIndexSignature' ||
propSignature.type === 'TSConstructSignatureDeclaration' ||
propSignature.type === 'TSCallSignatureDeclaration'
) {
return undefined;
}
if (propSignature.typeAnnotation && propSignature.typeAnnotation.typeAnnotation.type === 'TSTypeLiteral') {
Expand Down
18 changes: 18 additions & 0 deletions test/rules/assertions/checkParamNames.js
Expand Up @@ -1279,5 +1279,23 @@ export default {
checkDestructured: false,
}],
},
{
code: `
class A {
/**
* Show a prompt.
* @param hideButton true if button should be hidden, false otherwise
* @param onHidden delegate to call when the prompt is hidden
*/
public async showPrompt(hideButton: boolean, onHidden: {(): void}): Promise<void>
{
}
}
`,
parser: require.resolve('@typescript-eslint/parser'),
parserOptions: {
sourceType: 'module',
},
},
],
};

0 comments on commit 8341f97

Please sign in to comment.