@@ -2116,6 +2116,10 @@ namespace ts {
2116
2116
result = addRange ( result , getJSDocParameterTags ( node as ParameterDeclaration ) ) ;
2117
2117
break ;
2118
2118
}
2119
+ if ( node . kind === SyntaxKind . TypeParameter ) {
2120
+ result = addRange ( result , getJSDocTypeParameterTags ( node as TypeParameterDeclaration ) ) ;
2121
+ break ;
2122
+ }
2119
2123
node = getNextJSDocCommentLocation ( node ) ;
2120
2124
}
2121
2125
return result || emptyArray ;
@@ -4994,15 +4998,14 @@ namespace ts {
4994
4998
/**
4995
4999
* Gets the JSDoc parameter tags for the node if present.
4996
5000
*
4997
- * @remarks Returns any JSDoc param tag that matches the provided
5001
+ * @remarks Returns any JSDoc param tag whose name matches the provided
4998
5002
* parameter, whether a param tag on a containing function
4999
5003
* expression, or a param tag on a variable declaration whose
5000
5004
* initializer is the containing function. The tags closest to the
5001
5005
* node are returned first, so in the previous example, the param
5002
5006
* tag on the containing function expression would be first.
5003
5007
*
5004
- * Does not return tags for binding patterns, because JSDoc matches
5005
- * parameters by name and binding patterns do not have a name.
5008
+ * For binding patterns, parameter tags are matched by position.
5006
5009
*/
5007
5010
export function getJSDocParameterTags ( param : ParameterDeclaration ) : ReadonlyArray < JSDocParameterTag > {
5008
5011
if ( param . name ) {
@@ -5023,6 +5026,22 @@ namespace ts {
5023
5026
return emptyArray ;
5024
5027
}
5025
5028
5029
+ /**
5030
+ * Gets the JSDoc type parameter tags for the node if present.
5031
+ *
5032
+ * @remarks Returns any JSDoc template tag whose names match the provided
5033
+ * parameter, whether a template tag on a containing function
5034
+ * expression, or a template tag on a variable declaration whose
5035
+ * initializer is the containing function. The tags closest to the
5036
+ * node are returned first, so in the previous example, the template
5037
+ * tag on the containing function expression would be first.
5038
+ */
5039
+ export function getJSDocTypeParameterTags ( param : TypeParameterDeclaration ) : ReadonlyArray < JSDocTemplateTag > {
5040
+ const name = param . name . escapedText ;
5041
+ return getJSDocTags ( param . parent ) . filter ( ( tag ) : tag is JSDocTemplateTag =>
5042
+ isJSDocTemplateTag ( tag ) && tag . typeParameters . some ( tp => tp . name . escapedText === name ) ) ;
5043
+ }
5044
+
5026
5045
/**
5027
5046
* Return true if the node has JSDoc parameter tags.
5028
5047
*
0 commit comments