Skip to content

Commit

Permalink
fix: Skip declarations that are for the same location
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Malton <sebastian@malton.name>
  • Loading branch information
Nokel81 committed Aug 3, 2023
1 parent 263ee3a commit fc436f1
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit fc436f1

Please sign in to comment.