Skip to content

Commit

Permalink
Fix duplicate def in type hierarchy
Browse files Browse the repository at this point in the history
Resolves #2327
  • Loading branch information
Gerrit0 committed Jul 7, 2023
1 parent b005d53 commit 8fb9011
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
- Implemented several miscellaneous performance improvements to generate docs faster, this took the time to generate TypeDoc's
site from ~5.6 seconds to ~5.4 seconds.

### Bug Fixes

- Fixed duplicate definitions in type hierarchy when using packages mode, #2327.

## v0.24.8 (2023-06-04)

### Features
Expand Down
49 changes: 29 additions & 20 deletions src/lib/converter/plugins/TypePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export class TypePlugin extends ConverterComponent {

private onRevive(project: ProjectReflection) {
for (const id in project.reflections) {
this.resolve(project, project.reflections[id]);
this.resolve(
project,
project.reflections[id],
/* create links */ false
);
}
this.finishResolve(project);
this.reflections.clear();
Expand All @@ -44,38 +48,43 @@ export class TypePlugin extends ConverterComponent {
this.resolve(context.project, reflection);
}

private resolve(project: ProjectReflection, reflection: Reflection) {
private resolve(
project: ProjectReflection,
reflection: Reflection,
createLinks = true
) {
if (!(reflection instanceof DeclarationReflection)) return;

if (reflection.kindOf(ReflectionKind.ClassOrInterface)) {
this.postpone(reflection);

walk(reflection.implementedTypes, (target) => {
this.postpone(target);
if (!target.implementedBy) {
target.implementedBy = [];
target.implementedBy ||= [];
if (createLinks) {
target.implementedBy.push(
ReferenceType.createResolvedReference(
reflection.name,
reflection,
project
)
);
}
target.implementedBy.push(
ReferenceType.createResolvedReference(
reflection.name,
reflection,
project
)
);
});

walk(reflection.extendedTypes, (target) => {
this.postpone(target);
if (!target.extendedBy) {
target.extendedBy = [];
target.extendedBy ||= [];

if (createLinks) {
target.extendedBy.push(
ReferenceType.createResolvedReference(
reflection.name,
reflection,
project
)
);
}
target.extendedBy.push(
ReferenceType.createResolvedReference(
reflection.name,
reflection,
project
)
);
});
}

Expand Down

0 comments on commit 8fb9011

Please sign in to comment.