Skip to content

Commit 3ba8469

Browse files
Guard against undefined module bodies in navbar/navtree.
1 parent f230a5a commit 3ba8469

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/services/navigationBar.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,10 @@ namespace ts.NavigationBar {
650650
// We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes.
651651
// Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'!
652652
function areSameModule(a: ModuleDeclaration, b: ModuleDeclaration): boolean {
653-
return a.body!.kind === b.body!.kind && (a.body!.kind !== SyntaxKind.ModuleDeclaration || areSameModule(a.body as ModuleDeclaration, b.body as ModuleDeclaration));
653+
if (!a.body || !b.body) {
654+
return a.body === b.body;
655+
}
656+
return a.body.kind === b.body.kind && (a.body.kind !== SyntaxKind.ModuleDeclaration || areSameModule(a.body as ModuleDeclaration, b.body as ModuleDeclaration));
654657
}
655658

656659
/** Merge source into target. Source should be thrown away after this is called. */

0 commit comments

Comments
 (0)