-
Notifications
You must be signed in to change notification settings - Fork 12.8k
[GH-43213] Fix duplicate comments printed in quick info section #43240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An idea for a simpler approach.
@@ -584,7 +584,17 @@ namespace ts { | |||
forEachUnique(declarations, declaration => { | |||
const inheritedDocs = findBaseOfDeclaration(checker, declaration, symbol => symbol.getDocumentationComment(checker)); | |||
// TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs | |||
if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(lineBreakPart(), doc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to write your own loop; findBaseOfDeclaration
allows you to skip base declarations by returning undefined, so you can maintain seen: Set<Symbol>
to allow you to skip a symbol that's been seen before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the outer forEachUnique might be redundant with this fix in place. Might be worth running tests once with it removed to see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GENUIS!
@sandersn |
I removed the forEachUnique since it wasn't really doing much in this case and replaced it with a normal for each loop. |
Fixes #43213
Only push values to the comments array if it's unique (similar to how we do it for declartation comments in let doc = JsDoc.getJsDocCommentsFromDeclarations)