Skip to content

Commit

Permalink
Fix getReflectionsFromSymbolId from returning undefined elements
Browse files Browse the repository at this point in the history
Returning [undefined] causes downstream TypeErrors.

Example:
```
TypeError: Cannot read properties of undefined (reading 'kindOf')
    at ./node_modules/typedoc/dist/lib/models/types.js:688:25
    at Array.find (<anonymous>)
    at get reflection [as reflection]
```
  • Loading branch information
Nicholas Bilyk committed Feb 29, 2024
1 parent 9999d54 commit 9ff23fd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "typedoc",
"description": "Create api documentation for TypeScript projects.",
"version": "0.25.9",
"version": "0.25.10",
"homepage": "https://typedoc.org",
"exports": {
".": "./dist/index.js",
Expand Down
8 changes: 6 additions & 2 deletions src/lib/models/reflections/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,13 @@ export class ProjectReflection extends ContainerReflection {
getReflectionsFromSymbolId(symbolId: ReflectionSymbolId) {
const id = this.symbolToReflectionIdMap.get(symbolId);
if (typeof id === "number") {
return [this.getReflectionById(id)!];
const refl = this.getReflectionById(id);
if (refl === undefined) return [];
return [refl];
} else if (typeof id === "object") {
return id.map((id) => this.getReflectionById(id)!);
return id
.map((id) => this.getReflectionById(id))
.filter((refl): refl is Reflection => refl !== undefined);
}

return [];
Expand Down

0 comments on commit 9ff23fd

Please sign in to comment.