Skip to content

Commit f92f5a8

Browse files
committed
Fix removeReflection when no symbol is registered
Resolves #2496
1 parent de4d813 commit f92f5a8

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
## Bug Fixes
1414

15+
- Fixed crash when `--excludeNotDocumented` was used and the project contained a reference to a removed signature, #2496.
1516
- Fixed an issue where a namespace would not be created for merged function-namespaces which are declared as variables, #2478.
1617
- A class which implements itself will no longer cause a crash when rendering HTML, #2495.
1718
- Variable functions which have construct signatures will no longer be converted as functions, ignoring the construct signatures.

src/lib/models/reflections/project.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,17 @@ export class ProjectReflection extends ContainerReflection {
236236
this.reflectionChildren.delete(reflection.id);
237237

238238
// Remove references from the TS symbol to this reflection.
239-
const symbol = this.reflectionIdToSymbolMap.get(reflection.id);
240-
if (symbol) {
241-
const id = new ReflectionSymbolId(symbol);
242-
const saved = this.symbolToReflectionIdMap.get(id);
239+
const symbolId = this.reflectionIdToSymbolIdMap.get(reflection.id);
240+
if (symbolId) {
241+
const saved = this.symbolToReflectionIdMap.get(symbolId);
243242
if (saved === reflection.id) {
244-
this.symbolToReflectionIdMap.delete(id);
243+
this.symbolToReflectionIdMap.delete(symbolId);
245244
} else if (typeof saved === "object") {
246245
removeIfPresent(saved, reflection.id);
247246
}
248247
}
249248

249+
this.reflectionIdToSymbolMap.delete(reflection.id);
250250
this.reflectionIdToSymbolIdMap.delete(reflection.id);
251251
delete this.reflections[reflection.id];
252252
}

src/test/converter2/issues/gh2496.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export function f() {
2+
return 1;
3+
}
4+
5+
/** doc */
6+
export type ReturnOfF = ReturnType<typeof f>;

src/test/issues.c2.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,4 +1383,9 @@ describe("Issue Tests", () => {
13831383
const context = theme.getRenderContext(page);
13841384
context.hierarchyTemplate(page);
13851385
});
1386+
1387+
it("Correctly cleans up references to functions #2496", () => {
1388+
app.options.setValue("excludeNotDocumented", true);
1389+
convert();
1390+
});
13861391
});

0 commit comments

Comments
 (0)