This repository was archived by the owner on Aug 18, 2021. It is now read-only.
File tree 2 files changed +16
-3
lines changed
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,18 @@ function monkeypatch() {
176
176
}
177
177
}
178
178
179
+ function visitTypeParameters ( typeParameters ) {
180
+ var params = typeParameters . params ;
181
+
182
+ // visit bounds on polymorphpic types, eg; `Foo` in `fn<T: Foo>(a: T): T`
183
+ for ( var i = 0 ; i < params . length ; i ++ ) {
184
+ var param = params [ i ] ;
185
+ if ( param . typeAnnotation ) {
186
+ visitTypeAnnotation . call ( this , param . typeAnnotation ) ;
187
+ }
188
+ }
189
+ }
190
+
179
191
function checkIdentifierOrVisit ( node ) {
180
192
if ( node . typeAnnotation ) {
181
193
visitTypeAnnotation . call ( this , node . typeAnnotation ) ;
@@ -249,6 +261,7 @@ function monkeypatch() {
249
261
var typeParamScope ;
250
262
if ( node . typeParameters ) {
251
263
typeParamScope = nestTypeParamScope ( this . scopeManager , node ) ;
264
+ visitTypeParameters . call ( this , node . typeParameters ) ;
252
265
}
253
266
if ( node . returnType ) {
254
267
checkIdentifierOrVisit . call ( this , node . returnType ) ;
Original file line number Diff line number Diff line change @@ -222,13 +222,13 @@ describe("verify", () => {
222
222
) ;
223
223
} ) ;
224
224
225
- it ( "type parameters " , ( ) => {
225
+ it ( "type parameter bounds " , ( ) => {
226
226
verifyAndAssertMessages (
227
227
unpad ( `
228
228
import type Foo from 'foo';
229
229
import type Foo2 from 'foo';
230
- function log<T1, T2>(a: T1, b: T2) { return a + b; }
231
- log<Foo, Foo2> (1, 2);
230
+ function log<T1: Foo , T2: Foo2 >(a: T1, b: T2) { return a + b; }
231
+ log(1, 2);
232
232
` ) ,
233
233
{ "no-unused-vars" : 1 , "no-undef" : 1 } ,
234
234
[ ]
You can’t perform that action at this time.
0 commit comments