Skip to content

Commit

Permalink
Fix removeReflection when no symbol is registered
Browse files Browse the repository at this point in the history
Resolves #2496
  • Loading branch information
Gerrit0 committed Feb 23, 2024
1 parent de4d813 commit f92f5a8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@

## Bug Fixes

- Fixed crash when `--excludeNotDocumented` was used and the project contained a reference to a removed signature, #2496.
- Fixed an issue where a namespace would not be created for merged function-namespaces which are declared as variables, #2478.
- A class which implements itself will no longer cause a crash when rendering HTML, #2495.
- Variable functions which have construct signatures will no longer be converted as functions, ignoring the construct signatures.
Expand Down
10 changes: 5 additions & 5 deletions src/lib/models/reflections/project.ts
Expand Up @@ -236,17 +236,17 @@ export class ProjectReflection extends ContainerReflection {
this.reflectionChildren.delete(reflection.id);

// Remove references from the TS symbol to this reflection.
const symbol = this.reflectionIdToSymbolMap.get(reflection.id);
if (symbol) {
const id = new ReflectionSymbolId(symbol);
const saved = this.symbolToReflectionIdMap.get(id);
const symbolId = this.reflectionIdToSymbolIdMap.get(reflection.id);
if (symbolId) {
const saved = this.symbolToReflectionIdMap.get(symbolId);
if (saved === reflection.id) {
this.symbolToReflectionIdMap.delete(id);
this.symbolToReflectionIdMap.delete(symbolId);
} else if (typeof saved === "object") {
removeIfPresent(saved, reflection.id);
}
}

this.reflectionIdToSymbolMap.delete(reflection.id);
this.reflectionIdToSymbolIdMap.delete(reflection.id);
delete this.reflections[reflection.id];
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/converter2/issues/gh2496.ts
@@ -0,0 +1,6 @@
export function f() {
return 1;
}

/** doc */
export type ReturnOfF = ReturnType<typeof f>;
5 changes: 5 additions & 0 deletions src/test/issues.c2.test.ts
Expand Up @@ -1383,4 +1383,9 @@ describe("Issue Tests", () => {
const context = theme.getRenderContext(page);
context.hierarchyTemplate(page);
});

it("Correctly cleans up references to functions #2496", () => {
app.options.setValue("excludeNotDocumented", true);
convert();
});
});

0 comments on commit f92f5a8

Please sign in to comment.