From 3ba84692c62e1683c0a2c59db2f33781a0b09e72 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 12 Jan 2022 01:21:48 +0000 Subject: [PATCH] Guard against undefined module bodies in navbar/navtree. --- src/services/navigationBar.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 6f9cdd55950..6b0e4869eb1 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -650,7 +650,10 @@ namespace ts.NavigationBar { // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a: ModuleDeclaration, b: ModuleDeclaration): boolean { - return a.body!.kind === b.body!.kind && (a.body!.kind !== SyntaxKind.ModuleDeclaration || areSameModule(a.body as ModuleDeclaration, b.body as ModuleDeclaration)); + if (!a.body || !b.body) { + return a.body === b.body; + } + return a.body.kind === b.body.kind && (a.body.kind !== SyntaxKind.ModuleDeclaration || areSameModule(a.body as ModuleDeclaration, b.body as ModuleDeclaration)); } /** Merge source into target. Source should be thrown away after this is called. */