Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃 Pick PR #47395 (Fix for crash in navbar with double...) into release-4.5 #47421

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/services/navigationBar.ts
Expand Up @@ -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. */
Expand Down
24 changes: 24 additions & 0 deletions tests/cases/fourslash/navbarForDoubleAmbientModules01.ts
@@ -0,0 +1,24 @@
/// <reference path="./fourslash.ts" />

//// declare module "foo";
//// declare module "foo";

verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "\"foo\"",
"kind": "module",
"kindModifiers": "declare"
}
]
},
{
"text": "\"foo\"",
"kind": "module",
"kindModifiers": "declare",
"indent": 1
}
]);