diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts
index b4c32d566b126..69b36b9ee8a36 100644
--- a/src/services/navigationBar.ts
+++ b/src/services/navigationBar.ts
@@ -59,6 +59,7 @@ import {
isBindingPattern,
isCallExpression,
isClassDeclaration,
+ isClassExpression,
isClassLike,
isComputedPropertyName,
isDeclaration,
@@ -104,6 +105,7 @@ import {
removeFileExtension,
setTextRange,
ShorthandPropertyAssignment,
+ skipOuterExpressions,
SourceFile,
SpreadAssignment,
SyntaxKind,
@@ -444,8 +446,8 @@ function addChildrenRecursively(node: Node | undefined): void {
break;
case SyntaxKind.ExportAssignment: {
- const expression = (node as ExportAssignment).expression;
- const child = isObjectLiteralExpression(expression) || isCallExpression(expression) ? expression :
+ const expression = skipOuterExpressions((node as ExportAssignment).expression);
+ const child = isObjectLiteralExpression(expression) || isCallExpression(expression) || isClassExpression(expression) ? expression :
isArrowFunction(expression) || isFunctionExpression(expression) ? expression.body : undefined;
if (child) {
startNode(node);
diff --git a/tests/cases/fourslash/navigationItemsExportDefaultExpression2.ts b/tests/cases/fourslash/navigationItemsExportDefaultExpression2.ts
new file mode 100644
index 0000000000000..bb2540634977a
--- /dev/null
+++ b/tests/cases/fourslash/navigationItemsExportDefaultExpression2.ts
@@ -0,0 +1,131 @@
+///
+
+//// export const foo = {
+//// foo: {},
+//// };
+////
+//// export default {
+//// foo: {},
+//// };
+////
+//// export default {
+//// foo: {},
+//// };
+////
+//// type Type = typeof foo;
+////
+//// export default {
+//// foo: {},
+//// } as Type;
+////
+//// export default {
+//// foo: {},
+//// } satisfies Type;
+////
+//// export default (class {
+//// prop = 42;
+//// });
+////
+//// export default (class Cls {
+//// prop = 42;
+//// });
+
+verify.navigationTree({
+ text: '"navigationItemsExportDefaultExpression2"',
+ kind: "module",
+ childItems: [
+ {
+ text: "default",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "foo",
+ kind: "property",
+ },
+ ],
+ },
+ {
+ text: "default",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "foo",
+ kind: "property",
+ },
+ ],
+ },
+ {
+ text: "default",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "foo",
+ kind: "property",
+ },
+ ],
+ },
+ {
+ text: "default",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "foo",
+ kind: "property",
+ },
+ ],
+ },
+ {
+ text: "default",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "",
+ kind: "class",
+ childItems: [
+ {
+ text: "prop",
+ kind: "property",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ text: "default",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "Cls",
+ kind: "class",
+ childItems: [
+ {
+ text: "prop",
+ kind: "property",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ text: "foo",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "foo",
+ kind: "property",
+ },
+ ],
+ },
+ {
+ text: "Type",
+ kind: "type",
+ },
+ ],
+});
diff --git a/tests/cases/fourslash/navigationItemsExportEqualsExpression.ts b/tests/cases/fourslash/navigationItemsExportEqualsExpression.ts
index 68bc12716731e..29874e3984739 100644
--- a/tests/cases/fourslash/navigationItemsExportEqualsExpression.ts
+++ b/tests/cases/fourslash/navigationItemsExportEqualsExpression.ts
@@ -29,6 +29,9 @@
//// d: 1
//// }
//// }
+////
+//// function foo(props: { x: number; y: number }) {}
+//// export = foo({ x: 1, y: 1 });
verify.navigationTree({
"text": '"navigationItemsExportEqualsExpression"',
@@ -85,7 +88,13 @@ verify.navigationTree({
{
"text": "export=",
"kind": "class",
- "kindModifiers": "export"
+ "kindModifiers": "export",
+ "childItems": [
+ {
+ "text": "AB",
+ "kind": "class"
+ }
+ ]
},
{
"text": "export=",
@@ -112,6 +121,21 @@ verify.navigationTree({
}
]
},
+ {
+ "text": "export=",
+ "kind": "const",
+ "kindModifiers": "export",
+ "childItems": [
+ {
+ "text": "x",
+ "kind": "property"
+ },
+ {
+ "text": "y",
+ "kind": "property"
+ }
+ ]
+ },
{
"text": "abc",
"kind": "const"
@@ -120,7 +144,10 @@ verify.navigationTree({
"text": "export=",
"kind": "const",
"kindModifiers": "export"
+ },
+ {
+ "text": "foo",
+ "kind": "function"
}
]
});
-
diff --git a/tests/cases/fourslash/navigationItemsExportEqualsExpression2.ts b/tests/cases/fourslash/navigationItemsExportEqualsExpression2.ts
new file mode 100644
index 0000000000000..d8683dc4ffc55
--- /dev/null
+++ b/tests/cases/fourslash/navigationItemsExportEqualsExpression2.ts
@@ -0,0 +1,131 @@
+///
+
+//// export const foo = {
+//// foo: {},
+//// };
+////
+//// export = {
+//// foo: {},
+//// };
+////
+//// export = {
+//// foo: {},
+//// };
+////
+//// type Type = typeof foo;
+////
+//// export = {
+//// foo: {},
+//// } as Type;
+////
+//// export = {
+//// foo: {},
+//// } satisfies Type;
+////
+//// export = (class {
+//// prop = 42;
+//// });
+////
+//// export = (class Cls {
+//// prop = 42;
+//// });
+
+verify.navigationTree({
+ text: '"navigationItemsExportEqualsExpression2"',
+ kind: "module",
+ childItems: [
+ {
+ text: "export=",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "foo",
+ kind: "property",
+ },
+ ],
+ },
+ {
+ text: "export=",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "foo",
+ kind: "property",
+ },
+ ],
+ },
+ {
+ text: "export=",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "foo",
+ kind: "property",
+ },
+ ],
+ },
+ {
+ text: "export=",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "foo",
+ kind: "property",
+ },
+ ],
+ },
+ {
+ text: "export=",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "",
+ kind: "class",
+ childItems: [
+ {
+ text: "prop",
+ kind: "property",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ text: "export=",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "Cls",
+ kind: "class",
+ childItems: [
+ {
+ text: "prop",
+ kind: "property",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ text: "foo",
+ kind: "const",
+ kindModifiers: "export",
+ childItems: [
+ {
+ text: "foo",
+ kind: "property",
+ },
+ ],
+ },
+ {
+ text: "Type",
+ kind: "type",
+ },
+ ],
+});