diff --git a/src/server/session.ts b/src/server/session.ts index 846a9e0df85..a15d6c530c4 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -853,11 +853,7 @@ namespace ts.server { if (simplifiedResult) { const displayString = ts.displayPartsToString(quickInfo.displayParts); const docString = ts.displayPartsToString(quickInfo.documentation); - let tags: ts.JSDocTagInfo[] = []; - if (quickInfo.tags) { - tags = quickInfo.tags; - } - + return { kind: quickInfo.kind, kindModifiers: quickInfo.kindModifiers, @@ -865,7 +861,7 @@ namespace ts.server { end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), displayString: displayString, documentation: docString, - tags: tags + tags: quickInfo.tags || [] }; } else { diff --git a/src/services/completions.ts b/src/services/completions.ts index 7b80c7b7d2f..38792026a2e 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -759,14 +759,14 @@ namespace ts.Completions { const symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location) === entryName ? s : undefined); if (symbol) { - const { displayParts, documentation, symbolKind, jsDocTags } = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location, location, SemanticMeaning.All); + const { displayParts, documentation, symbolKind, tags } = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location, location, SemanticMeaning.All); return { name: entryName, kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), kind: symbolKind, displayParts, documentation, - tags: jsDocTags + tags }; } } diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 831a500744b..ce9d8718699 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -76,19 +76,14 @@ namespace ts.JsDoc { if (!jsDocs) { return; } - const jsDocTags: JSDocTag[] = []; - jsDocs.forEach(doc => { + for (const doc of jsDocs) { const tagsForDoc = (doc as JSDoc).tags; if (tagsForDoc) { - jsDocTags.push(...tagsForDoc.filter(tag => tag.kind === SyntaxKind.JSDocTag)); - } - }); - if (!jsDocTags) { - return; - } - for (const tag of jsDocTags) { - if (tag) { - tags.push({ name: tag.tagName.text, text: tag.comment }); + tags.push(...tagsForDoc.filter(tag => tag.kind === SyntaxKind.JSDocTag).map(jsDocTag => { + return { + name: jsDocTag.tagName.text, + text: jsDocTag.comment + } })); } } }); diff --git a/src/services/services.ts b/src/services/services.ts index 5d757e33f87..93993a6c1df 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1355,7 +1355,7 @@ namespace ts { textSpan: createTextSpan(node.getStart(), node.getWidth()), displayParts: displayPartsDocumentationsAndKind.displayParts, documentation: displayPartsDocumentationsAndKind.documentation, - tags: displayPartsDocumentationsAndKind.jsDocTags + tags: displayPartsDocumentationsAndKind.tags }; } diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index ca91a4cc545..c29200fcb0d 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -89,7 +89,7 @@ namespace ts.SymbolDisplay { const displayParts: SymbolDisplayPart[] = []; let documentation: SymbolDisplayPart[]; - let jsDocTags: JSDocTagInfo[]; + let tags: JSDocTagInfo[]; const symbolFlags = symbol.flags; let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); let hasAddedSymbolInfo: boolean; @@ -408,7 +408,7 @@ namespace ts.SymbolDisplay { if (!documentation) { documentation = symbol.getDocumentationComment(); - jsDocTags = symbol.getJsDocTags(); + tags = symbol.getJsDocTags(); if (documentation.length === 0 && symbol.flags & SymbolFlags.Property) { // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. @@ -425,7 +425,7 @@ namespace ts.SymbolDisplay { } documentation = rhsSymbol.getDocumentationComment(); - jsDocTags = rhsSymbol.getJsDocTags(); + tags = rhsSymbol.getJsDocTags(); if (documentation.length > 0) { break; } @@ -434,7 +434,7 @@ namespace ts.SymbolDisplay { } } - return { displayParts, documentation, symbolKind, jsDocTags }; + return { displayParts, documentation, symbolKind, tags }; function addNewLineIfDisplayPartsExist() { if (displayParts.length) { @@ -492,7 +492,7 @@ namespace ts.SymbolDisplay { displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); } documentation = signature.getDocumentationComment(); - jsDocTags = signature.getJsDocTags(); + tags = signature.getJsDocTags(); } function writeTypeParametersOfSymbol(symbol: Symbol, enclosingDeclaration: Node) {