fix(38785): include in NavigationBar child items from default exported functions (#38915)

This commit is contained in:
Alexander T
2020-06-26 09:35:27 -07:00
committed by GitHub
parent 535914c6d5
commit 59f80970d9
3 changed files with 115 additions and 5 deletions
+4 -2
View File
@@ -310,9 +310,11 @@ namespace ts.NavigationBar {
case SyntaxKind.ExportAssignment: {
const expression = (<ExportAssignment>node).expression;
if (isObjectLiteralExpression(expression)) {
const child = isObjectLiteralExpression(expression) ? expression :
isArrowFunction(expression) || isFunctionExpression(expression) ? expression.body : undefined;
if (child) {
startNode(node);
addChildrenRecursively(expression);
addChildrenRecursively(child);
endNode();
}
else {
@@ -1,8 +1,24 @@
/// <reference path="fourslash.ts"/>
//// const abc = 12;
//// export default function () {}
//// export default function () {
//// return class Foo {
//// }
//// }
////
//// export default () => ""
//// export default () => {
//// return class Foo {
//// }
//// }
////
//// export default function f1() {}
//// export default function f2() {
//// return class Foo {
//// }
//// }
////
//// const abc = 12;
//// export default abc;
//// export default class AB {}
//// export default {
@@ -22,11 +38,33 @@ verify.navigationTree({
"kind": "function",
"kindModifiers": "export"
},
{
"text": "default",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
},
{
"text": "default",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "default",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
},
{
"text": "default",
"kind": "const",
@@ -65,6 +103,22 @@ verify.navigationTree({
"text": "default",
"kind": "const",
"kindModifiers": "export"
},
{
"text": "f1",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "f2",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
}
]
});
@@ -1,10 +1,26 @@
// 35477
/// <reference path="fourslash.ts"/>
//// export = function () {}
//// export = function () {
//// return class Foo {
//// }
//// }
////
//// export = () => ""
//// export = () => {
//// return class Foo {
//// }
//// }
////
//// export = function f1() {}
//// export = function f2() {
//// return class Foo {
//// }
//// }
////
//// const abc = 12;
//// export = abc;
//// export = function () {}
//// export = () => ""
//// export = class AB {}
//// export = {
//// a: 1,
@@ -23,11 +39,49 @@ verify.navigationTree({
"kind": "function",
"kindModifiers": "export"
},
{
"text": "export=",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
},
{
"text": "export=",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "export=",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
},
{
"text": "export=",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "export=",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
},
{
"text": "export=",
"kind": "class",