Skip to content

Commit be7be59

Browse files
committed
Make getJSDocTags public too
1 parent 058d355 commit be7be59

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/compiler/utilities.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,16 +1502,7 @@ namespace ts {
15021502
return getJSDocCommentsAndTags(node);
15031503
}
15041504

1505-
export function getJSDocTags(node: Node): ReadonlyArray<JSDocTag> | undefined {
1506-
let tags = node.jsDocCache;
1507-
// If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing.
1508-
if (tags === undefined) {
1509-
node.jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j);
1510-
}
1511-
return tags;
1512-
}
1513-
1514-
function getJSDocCommentsAndTags(node: Node): (JSDoc | JSDocTag)[] {
1505+
export function getJSDocCommentsAndTags(node: Node): (JSDoc | JSDocTag)[] {
15151506
let result: Array<JSDoc | JSDocTag> | undefined;
15161507
getJSDocCommentsAndTagsWorker(node);
15171508
return result || emptyArray;
@@ -4023,11 +4014,22 @@ namespace ts {
40234014
return returnTag && returnTag.typeExpression && returnTag.typeExpression.type;
40244015
}
40254016

4026-
/* Get the first JSDoc tag of a specified kind, or undefined if not present. */
4017+
/** Get all JSDoc tags related to a node, including those on parent nodes. */
4018+
export function getJSDocTags(node: Node): ReadonlyArray<JSDocTag> | undefined {
4019+
let tags = node.jsDocCache;
4020+
// If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing.
4021+
if (tags === undefined) {
4022+
node.jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j);
4023+
}
4024+
return tags;
4025+
}
4026+
4027+
/** Get the first JSDoc tag of a specified kind, or undefined if not present. */
40274028
function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag | undefined {
40284029
const tags = getJSDocTags(node);
40294030
return find(tags, doc => doc.kind === kind);
40304031
}
4032+
40314033
}
40324034

40334035
// Simple node tests of the form `node.kind === SyntaxKind.Foo`.

0 commit comments

Comments
 (0)