diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index b537a56e856..2d06177e128 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -155,18 +155,18 @@ namespace ts.NavigationBar { switch (node.kind) { case SyntaxKind.ClassDeclaration: topLevelNodes.push(node); - forEach((node).members, (node) => { - if (node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.Constructor) { + for (const member of (node).members) { + if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.Constructor) { type FunctionLikeMember = MethodDeclaration | ConstructorDeclaration; - if ((node).body) { + if ((member).body) { // We do not include methods that does not have child functions in it, because of duplications. - if (hasNonAnonymousFunctionDeclarations(((node).body).statements)) { - topLevelNodes.push(node); + if (hasNamedFunctionDeclarations(((member).body).statements)) { + topLevelNodes.push(member); } - addTopLevelNodes(((node).body).statements, topLevelNodes); + addTopLevelNodes(((member).body).statements, topLevelNodes); } } - }); + } break; case SyntaxKind.EnumDeclaration: case SyntaxKind.InterfaceDeclaration: @@ -190,7 +190,7 @@ namespace ts.NavigationBar { } } - function hasNonAnonymousFunctionDeclarations(nodes: NodeArray) { + function hasNamedFunctionDeclarations(nodes: NodeArray) { if (forEach(nodes, s => s.kind === SyntaxKind.FunctionDeclaration && !isEmpty((s).name.text))) { return true; } @@ -202,12 +202,11 @@ namespace ts.NavigationBar { // within it. if (functionDeclaration.body && functionDeclaration.body.kind === SyntaxKind.Block) { // Proper function declarations can only have identifier names - if (hasNonAnonymousFunctionDeclarations((functionDeclaration.body).statements)) { - + if (hasNamedFunctionDeclarations((functionDeclaration.body).statements)) { return true; } - // Or if it is not parented by another function(except for parent functions that + // Or if it is not parented by another function (except for parent functions that // are methods and constructors). I.e all functions at module scope are 'top level'. if (!isFunctionBlock(functionDeclaration.parent)) { return true;