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 @@ -189,20 +189,23 @@ const curryUtils = (
189
189
return false ;
190
190
} ;
191
191
192
- utils . classHasTag = ( tagName ) => {
192
+ utils . getClassJsdoc = ( ) => {
193
193
const classNode = utils . getClassNode ( ) ;
194
194
const classJsdocNode = getJSDocComment ( sourceCode , classNode ) ;
195
195
196
196
if ( classJsdocNode ) {
197
197
const indent = _ . repeat ( ' ' , classJsdocNode . loc . start . column ) ;
198
- const classJsdoc = parseComment ( classJsdocNode , indent ) ;
199
198
200
- if ( jsdocUtils . hasTag ( classJsdoc , tagName ) ) {
201
- return true ;
202
- }
199
+ return parseComment ( classJsdocNode , indent ) ;
203
200
}
204
201
205
- return false ;
202
+ return null ;
203
+ } ;
204
+
205
+ utils . classHasTag = ( tagName ) => {
206
+ const classJsdoc = utils . getClassJsdoc ( ) ;
207
+
208
+ return classJsdoc && jsdocUtils . hasTag ( classJsdoc , tagName ) ;
206
209
} ;
207
210
208
211
utils . forEachTag = ( tagName , arrayHandler ) => {
Original file line number Diff line number Diff line change @@ -67,6 +67,18 @@ export default iterateJsdoc(({
67
67
} )
68
68
. value ( ) ;
69
69
70
+ let closureGenericTypes = [ ] ;
71
+ const classJsdoc = utils . getClassJsdoc ( ) ;
72
+ if ( classJsdoc && classJsdoc . tags ) {
73
+ closureGenericTypes = classJsdoc . tags
74
+ . filter ( ( tag ) => {
75
+ return tag . tag === 'template' ;
76
+ } )
77
+ . map ( ( tag ) => {
78
+ return tag . name ;
79
+ } ) ;
80
+ }
81
+
70
82
const allDefinedTypes = globalScope . variables . map ( ( variable ) => {
71
83
return variable . name ;
72
84
} )
@@ -89,7 +101,8 @@ export default iterateJsdoc(({
89
101
. concat ( extraTypes )
90
102
. concat ( typedefDeclarations )
91
103
. concat ( definedTypes )
92
- . concat ( definedPreferredTypes ) ;
104
+ . concat ( definedPreferredTypes )
105
+ . concat ( closureGenericTypes ) ;
93
106
94
107
const jsdocTags = utils . filterTags ( ( tag ) => {
95
108
return utils . isTagWithType ( tag . tag ) ;
Original file line number Diff line number Diff line change @@ -393,6 +393,20 @@ export default {
393
393
}
394
394
}
395
395
}
396
+ } ,
397
+ {
398
+ code : `
399
+ /**
400
+ * @template TEMPLATE_TYPE
401
+ */
402
+ class Foo {
403
+ /**
404
+ * @return {TEMPLATE_TYPE}
405
+ */
406
+ bar () {
407
+ }
408
+ }
409
+ `
396
410
}
397
411
]
398
412
} ;
You can’t perform that action at this time.
0 commit comments