navigationBar: Fix bug for shorthand ambient module (#25992)

This commit is contained in:
Andy 2018-07-26 17:27:12 -07:00 committed by GitHub
parent af3f737451
commit 3bfe91cdd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View File

@ -612,7 +612,7 @@ namespace ts.NavigationBar {
* We store 'A' as associated with a NavNode, and use getModuleName to traverse down again.
*/
function getInteriorModule(decl: ModuleDeclaration): ModuleDeclaration {
return decl.body!.kind === SyntaxKind.ModuleDeclaration ? getInteriorModule(<ModuleDeclaration>decl.body) : decl; // TODO: GH#18217
return decl.body && isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl;
}
function isComputedProperty(member: EnumMember): boolean {

View File

@ -4,6 +4,8 @@
////
////declare module 'X2.Y2.Z2' {}
////
////declare module "foo";
////
////module A.B.C {
//// export var x;
////}
@ -24,9 +26,6 @@
//// }
////}
//We have 8 module keywords, and 4 var keywords.
//The declarations of A.B.C.x do not get merged, so the 4 vars are independent.
//The two 'A' modules, however, do get merged, so in reality we have 7 modules.
verify.navigationTree({
"text": "<global>",
"kind": "script",
@ -36,6 +35,11 @@ verify.navigationTree({
"kind": "module",
"kindModifiers": "declare"
},
{
"text": "\"foo\"",
"kind": "module",
"kindModifiers": "declare"
},
{
"text": "\"X.Y.Z\"",
"kind": "module",
@ -104,6 +108,11 @@ verify.navigationBar([
"kind": "module",
"kindModifiers": "declare"
},
{
"text": "\"foo\"",
"kind": "module",
"kindModifiers": "declare"
},
{
"text": "\"X.Y.Z\"",
"kind": "module",
@ -129,6 +138,12 @@ verify.navigationBar([
"kindModifiers": "declare",
"indent": 1
},
{
"text": "\"foo\"",
"kind": "module",
"kindModifiers": "declare",
"indent": 1
},
{
"text": "\"X.Y.Z\"",
"kind": "module",