mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Component commits:f230a5af47Add failing test.3ba84692c6Guard against undefined module bodies in navbar/navtree. Co-authored-by: Daniel Rosenwasser <drosen@microsoft.com>
This commit is contained in:
co-authored by
Daniel Rosenwasser
parent
0854a93040
commit
14016a7851
@@ -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. */
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]);
|
||||
Reference in New Issue
Block a user