Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/lib/converter/comments/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,20 @@ export function discoverComment(
// not the last one, since that will apply to the import or declaration.
const reverse = !symbol.declarations?.some(ts.isSourceFile);

const seenLocations = new Set<string>();
const discovered: DiscoveredComment[] = [];

for (const decl of symbol.declarations || []) {
const text = decl.getSourceFile().text;
const file = decl.getSourceFile();
const text = file.text;
const location = `${file.fileName}:${decl.pos}`;

if (seenLocations.has(location)) {
continue;
} else {
seenLocations.add(location);
}

if (wantedKinds[kind].includes(decl.kind)) {
const node = declarationToCommentNode(decl);
if (!node) {
Expand Down Expand Up @@ -175,7 +185,7 @@ export function discoverComment(

if (selectedDocComment) {
discovered.push({
file: decl.getSourceFile(),
file,
ranges: selectedDocComment,
jsDoc: findJsDocForComment(node, selectedDocComment),
});
Expand Down