Merge pull request #38489 from microsoft/removeDuplicateInfo

Remove duplicate JSDoc comments
This commit is contained in:
Daniel Rosenwasser
2020-05-12 12:52:15 -07:00
committed by GitHub
4 changed files with 108 additions and 6 deletions

View File

@@ -89,17 +89,14 @@ namespace ts.JsDoc {
// Eg. const a: Array<string> | Array<number>; a.length
// The property length will have two declarations of property length coming
// from Array<T> - Array<string> and Array<number>
const documentationComment: SymbolDisplayPart[] = [];
const documentationComment: string[] = [];
forEachUnique(declarations, declaration => {
for (const { comment } of getCommentHavingNodes(declaration)) {
if (comment === undefined) continue;
if (documentationComment.length) {
documentationComment.push(lineBreakPart());
}
documentationComment.push(textPart(comment));
pushIfUnique(documentationComment, comment);
}
});
return documentationComment;
return intersperse(map(documentationComment, textPart), lineBreakPart());
}
function getCommentHavingNodes(declaration: Declaration): readonly (JSDoc | JSDocTag)[] {