Skip to content

Commit 6a83ae1

Browse files
authored
[GH-43213] Fix duplicate comments printed in quick info section (#43240)
* Concat on unique values * more changes * only push values to array if unique * address review comments * Fix lint * removw foeachunique
1 parent b925c16 commit 6a83ae1

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/services/services.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,17 @@ namespace ts {
581581

582582
let doc = JsDoc.getJsDocCommentsFromDeclarations(declarations);
583583
if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
584-
forEachUnique(declarations, declaration => {
585-
const inheritedDocs = findBaseOfDeclaration(checker, declaration, symbol => symbol.getDocumentationComment(checker));
584+
const seenSymbols = new Set<Symbol>();
585+
for (const declaration of declarations) {
586+
const inheritedDocs = findBaseOfDeclaration(checker, declaration, symbol => {
587+
if (!seenSymbols.has(symbol)) {
588+
seenSymbols.add(symbol);
589+
return symbol.getDocumentationComment(checker);
590+
}
591+
});
586592
// TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs
587593
if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(lineBreakPart(), doc);
588-
});
594+
}
589595
}
590596
return doc;
591597
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path="../fourslash.ts"/>
2+
3+
//// interface I {
4+
//// /** The colour */
5+
//// readonly colour: string
6+
//// }
7+
//// interface A extends I {
8+
//// readonly colour: "red" | "green";
9+
//// }
10+
//// interface B extends I {
11+
//// readonly colour: "yellow" | "green";
12+
//// }
13+
//// type F = A | B
14+
//// const f: F = { colour: "green" }
15+
//// f.colour/*1*/
16+
17+
goTo.marker("1")
18+
verify.quickInfoIs("(property) colour: \"red\" | \"green\" | \"yellow\"", "The colour")

0 commit comments

Comments
 (0)