From 5895493815ceebfa4e83d5ccdaaa5306cdd0b216 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Tue, 12 May 2020 17:26:31 +0300 Subject: [PATCH] fix(37877): include in NavigationBar default exported child items (#38255) --- src/services/navigationBar.ts | 13 +++++++- .../navigationItemsExportDefaultExpression.ts | 32 +++++++++++++++++++ .../navigationItemsExportEqualsExpression.ts | 32 +++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index b74da7fd8da..91bf61270de 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -307,7 +307,18 @@ namespace ts.NavigationBar { addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case SyntaxKind.ExportAssignment: + case SyntaxKind.ExportAssignment: { + const expression = (node).expression; + if (isObjectLiteralExpression(expression)) { + startNode(node); + addChildrenRecursively(expression); + endNode(); + } + else { + addLeafNode(node); + } + break; + } case SyntaxKind.ExportSpecifier: case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.IndexSignature: diff --git a/tests/cases/fourslash/navigationItemsExportDefaultExpression.ts b/tests/cases/fourslash/navigationItemsExportDefaultExpression.ts index 6425fd4bf7a..c3059d50c03 100644 --- a/tests/cases/fourslash/navigationItemsExportDefaultExpression.ts +++ b/tests/cases/fourslash/navigationItemsExportDefaultExpression.ts @@ -5,6 +5,13 @@ //// export default () => "" //// export default abc; //// export default class AB {} +//// export default { +//// a: 1, +//// b: 1, +//// c: { +//// d: 1 +//// } +//// } verify.navigationTree({ "text": '"navigationItemsExportDefaultExpression"', @@ -20,6 +27,31 @@ verify.navigationTree({ "kind": "function", "kindModifiers": "export" }, + { + "text": "default", + "kind": "const", + "kindModifiers": "export", + "childItems": [ + { + "text": "a", + "kind": "property" + }, + { + "text": "b", + "kind": "property" + }, + { + "text": "c", + "kind": "property", + "childItems": [ + { + "text": "d", + "kind": "property" + } + ] + } + ] + }, { "text": "AB", "kind": "class", diff --git a/tests/cases/fourslash/navigationItemsExportEqualsExpression.ts b/tests/cases/fourslash/navigationItemsExportEqualsExpression.ts index 053a1fa0023..f63db161b09 100644 --- a/tests/cases/fourslash/navigationItemsExportEqualsExpression.ts +++ b/tests/cases/fourslash/navigationItemsExportEqualsExpression.ts @@ -6,6 +6,13 @@ //// export = function () {} //// export = () => "" //// export = class AB {} +//// export = { +//// a: 1, +//// b: 1, +//// c: { +//// d: 1 +//// } +//// } verify.navigationTree({ "text": '"navigationItemsExportEqualsExpression"', @@ -26,6 +33,31 @@ verify.navigationTree({ "kind": "class", "kindModifiers": "export" }, + { + "text": "export=", + "kind": "const", + "kindModifiers": "export", + "childItems": [ + { + "text": "a", + "kind": "property" + }, + { + "text": "b", + "kind": "property" + }, + { + "text": "c", + "kind": "property", + "childItems": [ + { + "text": "d", + "kind": "property" + } + ] + } + ] + }, { "text": "abc", "kind": "const"