From 8341f97014449b7054750c630c99cff9a6f4e3b6 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Mon, 17 Aug 2020 23:24:53 +0800 Subject: [PATCH] fix(`check-param-names`): avoid erring upon `TSCallSignatureDeclaration`; fixes #624 --- README.md | 11 +++++++++++ src/jsdocUtils.js | 6 +++++- test/rules/assertions/checkParamNames.js | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c98d4a422..81172a787 100644 --- a/README.md +++ b/README.md @@ -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 + { + } +} ```` diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index e24580c62..1954f0d92 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -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') { diff --git a/test/rules/assertions/checkParamNames.js b/test/rules/assertions/checkParamNames.js index bca936eb1..34da21c0f 100644 --- a/test/rules/assertions/checkParamNames.js +++ b/test/rules/assertions/checkParamNames.js @@ -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 + { + } + } +`, + parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { + sourceType: 'module', + }, + }, ], };