Skip to content

Commit e76d594

Browse files
committed
Fix crash when class implements itself
Resolves #2495
1 parent eb7510b commit e76d594

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
## Bug Fixes
1010

1111
- Fixed an issue where a namespace would not be created for merged function-namespaces which are declared as variables, #2478.
12+
- A class which implements itself will no longer cause a crash when rendering HTML, #2495.
1213
- Variable functions which have construct signatures will no longer be converted as functions, ignoring the construct signatures.
1314
- Fixed an issue where, if the index section was collapsed when loading the page, all content within it would be hidden until expanded, and a member visibility checkbox was changed.
1415

src/lib/output/themes/default/templates/hierarchy.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import type { PageEvent } from "../../../events";
33
import { JSX } from "../../../../utils";
44
import { ReflectionKind, type ProjectReflection, DeclarationReflection } from "../../../../models";
55

6-
function fullHierarchy(context: DefaultThemeRenderContext, root: DeclarationReflection) {
6+
function fullHierarchy(
7+
context: DefaultThemeRenderContext,
8+
root: DeclarationReflection,
9+
seen = new Set<DeclarationReflection>(),
10+
) {
11+
if (seen.has(root)) return;
12+
seen.add(root);
13+
714
// Note: We don't use root.anchor for the anchor, because those are built on a per page basis.
815
// And classes/interfaces get their own page, so all the anchors will be empty anyways.
916
// Full name should be safe here, since this list only includes classes/interfaces.
@@ -16,10 +23,10 @@ function fullHierarchy(context: DefaultThemeRenderContext, root: DeclarationRefl
1623
</a>
1724
<ul>
1825
{root.implementedBy?.map((child) => {
19-
return child.reflection && fullHierarchy(context, child.reflection as DeclarationReflection);
26+
return child.reflection && fullHierarchy(context, child.reflection as DeclarationReflection, seen);
2027
})}
2128
{root.extendedBy?.map((child) => {
22-
return child.reflection && fullHierarchy(context, child.reflection as DeclarationReflection);
29+
return child.reflection && fullHierarchy(context, child.reflection as DeclarationReflection, seen);
2330
})}
2431
</ul>
2532
</li>

0 commit comments

Comments
 (0)