Skip to content

Commit 5895493

Browse files
authored
fix(37877): include in NavigationBar default exported child items (#38255)
1 parent f4872eb commit 5895493

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

src/services/navigationBar.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,18 @@ namespace ts.NavigationBar {
307307
addNodeWithRecursiveChild(node, getInteriorModule(<ModuleDeclaration>node).body);
308308
break;
309309

310-
case SyntaxKind.ExportAssignment:
310+
case SyntaxKind.ExportAssignment: {
311+
const expression = (<ExportAssignment>node).expression;
312+
if (isObjectLiteralExpression(expression)) {
313+
startNode(node);
314+
addChildrenRecursively(expression);
315+
endNode();
316+
}
317+
else {
318+
addLeafNode(node);
319+
}
320+
break;
321+
}
311322
case SyntaxKind.ExportSpecifier:
312323
case SyntaxKind.ImportEqualsDeclaration:
313324
case SyntaxKind.IndexSignature:

tests/cases/fourslash/navigationItemsExportDefaultExpression.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
//// export default () => ""
66
//// export default abc;
77
//// export default class AB {}
8+
//// export default {
9+
//// a: 1,
10+
//// b: 1,
11+
//// c: {
12+
//// d: 1
13+
//// }
14+
//// }
815

916
verify.navigationTree({
1017
"text": '"navigationItemsExportDefaultExpression"',
@@ -20,6 +27,31 @@ verify.navigationTree({
2027
"kind": "function",
2128
"kindModifiers": "export"
2229
},
30+
{
31+
"text": "default",
32+
"kind": "const",
33+
"kindModifiers": "export",
34+
"childItems": [
35+
{
36+
"text": "a",
37+
"kind": "property"
38+
},
39+
{
40+
"text": "b",
41+
"kind": "property"
42+
},
43+
{
44+
"text": "c",
45+
"kind": "property",
46+
"childItems": [
47+
{
48+
"text": "d",
49+
"kind": "property"
50+
}
51+
]
52+
}
53+
]
54+
},
2355
{
2456
"text": "AB",
2557
"kind": "class",

tests/cases/fourslash/navigationItemsExportEqualsExpression.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
//// export = function () {}
77
//// export = () => ""
88
//// export = class AB {}
9+
//// export = {
10+
//// a: 1,
11+
//// b: 1,
12+
//// c: {
13+
//// d: 1
14+
//// }
15+
//// }
916

1017
verify.navigationTree({
1118
"text": '"navigationItemsExportEqualsExpression"',
@@ -26,6 +33,31 @@ verify.navigationTree({
2633
"kind": "class",
2734
"kindModifiers": "export"
2835
},
36+
{
37+
"text": "export=",
38+
"kind": "const",
39+
"kindModifiers": "export",
40+
"childItems": [
41+
{
42+
"text": "a",
43+
"kind": "property"
44+
},
45+
{
46+
"text": "b",
47+
"kind": "property"
48+
},
49+
{
50+
"text": "c",
51+
"kind": "property",
52+
"childItems": [
53+
{
54+
"text": "d",
55+
"kind": "property"
56+
}
57+
]
58+
}
59+
]
60+
},
2961
{
3062
"text": "abc",
3163
"kind": "const"

0 commit comments

Comments
 (0)