Skip to content

Commit 6c6ddfe

Browse files
authored
fix(39899): include in NavigationBar default exported call expression arguments (#40412)
1 parent 0c08138 commit 6c6ddfe

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/services/navigationBar.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ namespace ts.NavigationBar {
310310

311311
case SyntaxKind.ExportAssignment: {
312312
const expression = (<ExportAssignment>node).expression;
313-
const child = isObjectLiteralExpression(expression) ? expression :
313+
const child = isObjectLiteralExpression(expression) || isCallExpression(expression) ? expression :
314314
isArrowFunction(expression) || isFunctionExpression(expression) ? expression.body : undefined;
315315
if (child) {
316316
startNode(node);
@@ -843,16 +843,11 @@ namespace ts.NavigationBar {
843843
}
844844

845845
// Otherwise, we need to aggregate each identifier to build up the qualified name.
846-
const result: string[] = [];
847-
848-
result.push(getTextOfIdentifierOrLiteral(moduleDeclaration.name));
849-
846+
const result = [getTextOfIdentifierOrLiteral(moduleDeclaration.name)];
850847
while (moduleDeclaration.body && moduleDeclaration.body.kind === SyntaxKind.ModuleDeclaration) {
851848
moduleDeclaration = <ModuleDeclaration>moduleDeclaration.body;
852-
853849
result.push(getTextOfIdentifierOrLiteral(moduleDeclaration.name));
854850
}
855-
856851
return result.join(".");
857852
}
858853

tests/cases/fourslash/navigationItemsExportDefaultExpression.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
//// d: 1
2929
//// }
3030
//// }
31+
////
32+
//// function foo(props: { x: number; y: number }) {}
33+
//// export default foo({ x: 1, y: 1 });
3134

3235
verify.navigationTree({
3336
"text": '"navigationItemsExportDefaultExpression"',
@@ -90,6 +93,21 @@ verify.navigationTree({
9093
}
9194
]
9295
},
96+
{
97+
"text": "default",
98+
"kind": "const",
99+
"kindModifiers": "export",
100+
"childItems": [
101+
{
102+
"text": "x",
103+
"kind": "property"
104+
},
105+
{
106+
"text": "y",
107+
"kind": "property"
108+
}
109+
]
110+
},
93111
{
94112
"text": "AB",
95113
"kind": "class",
@@ -119,6 +137,10 @@ verify.navigationTree({
119137
"kind": "class"
120138
}
121139
]
140+
},
141+
{
142+
"text": "foo",
143+
"kind": "function"
122144
}
123145
]
124146
});

0 commit comments

Comments
 (0)