Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/services/navigationBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
isBindingPattern,
isCallExpression,
isClassDeclaration,
isClassExpression,
isClassLike,
isComputedPropertyName,
isDeclaration,
Expand Down Expand Up @@ -104,6 +105,7 @@ import {
removeFileExtension,
setTextRange,
ShorthandPropertyAssignment,
skipOuterExpressions,
SourceFile,
SpreadAssignment,
SyntaxKind,
Expand Down Expand Up @@ -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);
Expand Down
131 changes: 131 additions & 0 deletions tests/cases/fourslash/navigationItemsExportDefaultExpression2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/// <reference path="fourslash.ts"/>

//// 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: "<class>",
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",
},
],
});
31 changes: 29 additions & 2 deletions tests/cases/fourslash/navigationItemsExportEqualsExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
//// d: 1
//// }
//// }
////
//// function foo(props: { x: number; y: number }) {}
//// export = foo({ x: 1, y: 1 });

verify.navigationTree({
"text": '"navigationItemsExportEqualsExpression"',
Expand Down Expand Up @@ -85,7 +88,13 @@ verify.navigationTree({
{
"text": "export=",
"kind": "class",
"kindModifiers": "export"
"kindModifiers": "export",
"childItems": [
{
"text": "AB",
"kind": "class"
}
]
},
{
"text": "export=",
Expand All @@ -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"
Expand All @@ -120,7 +144,10 @@ verify.navigationTree({
"text": "export=",
"kind": "const",
"kindModifiers": "export"
},
{
"text": "foo",
"kind": "function"
}
]
});

131 changes: 131 additions & 0 deletions tests/cases/fourslash/navigationItemsExportEqualsExpression2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/// <reference path="fourslash.ts"/>

//// 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: "<class>",
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",
},
],
});