Skip to content

Commit fe4efe8

Browse files
committed
Safety guard and couple of comments
1 parent f85911d commit fe4efe8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/services/navigationBar.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ namespace ts.NavigationBar {
566566
}
567567

568568
// Add a level if traversing into a container
569-
if (isFunctionLike(node) || isClassLike(node)) {
569+
if (newItem && (isFunctionLike(node) || isClassLike(node))) {
570570
const lastTop = topItem;
571571
indent++;
572572
topItem = newItem;
@@ -606,6 +606,7 @@ namespace ts.NavigationBar {
606606
case SyntaxKind.Constructor:
607607
case SyntaxKind.GetAccessor:
608608
case SyntaxKind.SetAccessor:
609+
// "export default function().." looks just like a regular function/class declaration, except with the 'default' flag set
609610
const name = node.flags && (node.flags & NodeFlags.Default) ? "default" :
610611
node.kind === SyntaxKind.Constructor ? "constructor" :
611612
declarationNameToString((node as (Declaration)).name);
@@ -633,6 +634,7 @@ namespace ts.NavigationBar {
633634
ScriptElementKind.memberFunctionElement,
634635
[getNodeSpan(node)]);
635636
case SyntaxKind.ExportAssignment:
637+
// e.g. "export default <expr>"
636638
return getNavBarItem("default", ScriptElementKind.variableElement, [getNodeSpan(node)]);
637639
case SyntaxKind.ImportClause: // e.g. 'def' in: import def from 'mod' (in ImportDeclaration)
638640
if (!(node as ImportClause).name) {

0 commit comments

Comments
 (0)