File tree Expand file tree Collapse file tree 3 files changed +37
-7
lines changed Expand file tree Collapse file tree 3 files changed +37
-7
lines changed Original file line number Diff line number Diff line change @@ -193,20 +193,23 @@ const curryUtils = (
193
193
return false ;
194
194
} ;
195
195
196
- utils . classHasTag = ( tagName ) => {
196
+ utils . getClassJsdoc = ( ) => {
197
197
const classNode = utils . getClassNode ( ) ;
198
198
const classJsdocNode = getJSDocComment ( sourceCode , classNode ) ;
199
199
200
200
if ( classJsdocNode ) {
201
201
const indent = _ . repeat ( ' ' , classJsdocNode . loc . start . column ) ;
202
- const classJsdoc = parseComment ( classJsdocNode , indent ) ;
203
202
204
- if ( jsdocUtils . hasTag ( classJsdoc , tagName ) ) {
205
- return true ;
206
- }
203
+ return parseComment ( classJsdocNode , indent ) ;
207
204
}
208
205
209
- return false ;
206
+ return null ;
207
+ } ;
208
+
209
+ utils . classHasTag = ( tagName ) => {
210
+ const classJsdoc = utils . getClassJsdoc ( ) ;
211
+
212
+ return classJsdoc && jsdocUtils . hasTag ( classJsdoc , tagName ) ;
210
213
} ;
211
214
212
215
utils . forEachTag = ( tagName , arrayHandler ) => {
Original file line number Diff line number Diff line change @@ -60,6 +60,18 @@ export default iterateJsdoc(({
60
60
} )
61
61
. value ( ) ;
62
62
63
+ let closureGenericTypes = [ ] ;
64
+ const classJsdoc = utils . getClassJsdoc ( ) ;
65
+ if ( classJsdoc && classJsdoc . tags ) {
66
+ closureGenericTypes = classJsdoc . tags
67
+ . filter ( ( tag ) => {
68
+ return tag . tag === 'template' ;
69
+ } )
70
+ . map ( ( tag ) => {
71
+ return tag . name ;
72
+ } ) ;
73
+ }
74
+
63
75
const allDefinedTypes = globalScope . variables . map ( ( variable ) => {
64
76
return variable . name ;
65
77
} )
@@ -82,7 +94,8 @@ export default iterateJsdoc(({
82
94
. concat ( extraTypes )
83
95
. concat ( typedefDeclarations )
84
96
. concat ( definedTypes )
85
- . concat ( definedPreferredTypes ) ;
97
+ . concat ( definedPreferredTypes )
98
+ . concat ( closureGenericTypes ) ;
86
99
87
100
const jsdocTags = utils . filterTags ( ( tag ) => {
88
101
return utils . isTagWithType ( tag . tag ) ;
Original file line number Diff line number Diff line change @@ -326,6 +326,20 @@ export default {
326
326
}
327
327
}
328
328
}
329
+ } ,
330
+ {
331
+ code : `
332
+ /**
333
+ * @template TEMPLATE_TYPE
334
+ */
335
+ class Foo {
336
+ /**
337
+ * @return {TEMPLATE_TYPE}
338
+ */
339
+ bar () {
340
+ }
341
+ }
342
+ `
329
343
}
330
344
]
331
345
} ;
You can’t perform that action at this time.
0 commit comments