fix(56602): JSDoc render with @param Sub-object properties (#56657)

This commit is contained in:
Oleksandr T
2023-12-13 23:02:14 +02:00
committed by GitHub
parent 0b03c80260
commit d84be8ed2d
3 changed files with 252 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ import {
CompletionEntry,
CompletionEntryDetails,
Completions,
concatenate,
ConstructorDeclaration,
contains,
Declaration,
@@ -258,17 +259,21 @@ export function getJsDocTagsFromDeclarations(declarations?: Declaration[], check
}
for (const tag of tags) {
infos.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) });
if (isJSDocPropertyLikeTag(tag) && tag.isNameFirst && tag.typeExpression && isJSDocTypeLiteral(tag.typeExpression.type)) {
forEach(tag.typeExpression.type.jsDocPropertyTags, propTag => {
infos.push({ name: propTag.tagName.text, text: getCommentDisplayParts(propTag, checker) });
});
}
infos.push(...getJSDocPropertyTagsInfo(tryGetJSDocPropertyTags(tag), checker));
}
});
return infos;
}
function getJSDocPropertyTagsInfo(nodes: readonly JSDocTag[] | undefined, checker: TypeChecker | undefined): readonly JSDocTagInfo[] {
return flatMap(nodes, propTag => concatenate([{ name: propTag.tagName.text, text: getCommentDisplayParts(propTag, checker) }], getJSDocPropertyTagsInfo(tryGetJSDocPropertyTags(propTag), checker)));
}
function tryGetJSDocPropertyTags(node: JSDocTag) {
return isJSDocPropertyLikeTag(node) && node.isNameFirst && node.typeExpression &&
isJSDocTypeLiteral(node.typeExpression.type) ? node.typeExpression.type.jsDocPropertyTags : undefined;
}
function getDisplayPartsFromComment(comment: string | readonly JSDocComment[], checker: TypeChecker | undefined): SymbolDisplayPart[] {
if (typeof comment === "string") {
return [textPart(comment)];