From 0a8ddca775ddcf0ec11616e3deea732e348fe3e8 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 18 Jul 2017 10:22:52 -0700 Subject: [PATCH] getJSDocParameterTags: no need to handle JSDocFunctionType, just return undefined (#16837) * getJSDocParameterTags: no need to handle JSDocFunctionType, just return undefined * Fix type error --- src/compiler/utilities.ts | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index ab0afb12820..a84e8eb8538 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1540,27 +1540,9 @@ namespace ts { } export function getJSDocParameterTags(param: ParameterDeclaration): JSDocParameterTag[] | undefined { - const func = param.parent; - const tags = getJSDocTags(func); - if (!tags) return undefined; - - if (!param.name) { - // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification - const paramIndex = func.parameters.indexOf(param); - Debug.assert(paramIndex !== -1); - let curParamIndex = 0; - for (const tag of tags) { - if (isJSDocParameterTag(tag)) { - if (curParamIndex === paramIndex) { - return [tag]; - } - curParamIndex++; - } - } - } - else if (param.name.kind === SyntaxKind.Identifier) { - const name = (param.name as Identifier).text; - return tags.filter((tag): tag is JSDocParameterTag => isJSDocParameterTag(tag) && tag.name.text === name) as JSDocParameterTag[]; + if (param.name && isIdentifier(param.name)) { + const name = param.name.text; + return getJSDocTags(param.parent).filter((tag): tag is JSDocParameterTag => isJSDocParameterTag(tag) && tag.name.text === name) as JSDocParameterTag[]; } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines