From e6610c5d54d753644d2bfabd32b67fb5c40d4add Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 19 Sep 2016 11:33:05 -0700 Subject: [PATCH] Handle msising tags for JsDoc nodes --- src/compiler/types.ts | 2 +- src/services/navigationBar.ts | 14 ++++++-------- .../navigationBarJsDocCommentWithNoTags.ts | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 tests/cases/fourslash/navigationBarJsDocCommentWithNoTags.ts diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b1b672d015b..e4bc9a29d5b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1604,7 +1604,7 @@ namespace ts { // @kind(SyntaxKind.JSDocComment) export interface JSDoc extends Node { - tags: NodeArray; + tags: NodeArray | undefined; comment: string | undefined; } diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index c2a5b745d3a..5c8c47e9666 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -218,15 +218,13 @@ namespace ts.NavigationBar { break; default: - if (node.jsDocComments) { - for (const jsDocComment of node.jsDocComments) { - for (const tag of jsDocComment.tags) { - if (tag.kind === SyntaxKind.JSDocTypedefTag) { - addLeafNode(tag); - } + forEach(node.jsDocComments, jsDocComment => { + forEach(jsDocComment.tags, tag => { + if (tag.kind === SyntaxKind.JSDocTypedefTag) { + addLeafNode(tag); } - } - } + }); + }); forEachChild(node, addChildrenRecursively); } diff --git a/tests/cases/fourslash/navigationBarJsDocCommentWithNoTags.ts b/tests/cases/fourslash/navigationBarJsDocCommentWithNoTags.ts new file mode 100644 index 00000000000..8746f135e4d --- /dev/null +++ b/tests/cases/fourslash/navigationBarJsDocCommentWithNoTags.ts @@ -0,0 +1,18 @@ +/// + +/////** Test */ +////export const Test = {} + +verify.navigationBar([ + { + "text": "\"navigationBarJsDocCommentWithNoTags\"", + "kind": "module", + "childItems": [ + { + "text": "Test", + "kind": "const", + "kindModifiers": "export" + } + ] + } +]);