mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 02:30:15 -06:00
getJSDocParameterTags: no need to handle JSDocFunctionType, just return undefined (#16837)
* getJSDocParameterTags: no need to handle JSDocFunctionType, just return undefined * Fix type error
This commit is contained in:
parent
fb89d47508
commit
0a8ddca775
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user