@@ -258,6 +258,13 @@ function collectTypeParameterUsageCounts(
258
258
}
259
259
}
260
260
261
+ // Catch-all: generic type references like `Exclude<T, null>`
262
+ else if ( type . aliasTypeArguments ) {
263
+ // We don't descend into the definition of the type alias, so we don't
264
+ // know whether it's used multiple times. It's safest to assume it is.
265
+ visitTypesList ( type . aliasTypeArguments , true ) ;
266
+ }
267
+
261
268
// Intersections and unions like `0 | 1`
262
269
else if ( tsutils . isUnionOrIntersectionType ( type ) ) {
263
270
visitTypesList ( type . types , assumeMultipleUses ) ;
@@ -288,9 +295,6 @@ function collectTypeParameterUsageCounts(
288
295
else if ( tsutils . isConditionalType ( type ) ) {
289
296
visitType ( type . checkType , assumeMultipleUses ) ;
290
297
visitType ( type . extendsType , assumeMultipleUses ) ;
291
- type . aliasTypeArguments ?. forEach ( typeArgument =>
292
- visitType ( typeArgument , false ) ,
293
- ) ;
294
298
}
295
299
296
300
// Catch-all: inferred object types like `{ K: V }`.
@@ -310,10 +314,6 @@ function collectTypeParameterUsageCounts(
310
314
}
311
315
}
312
316
313
- for ( const typeArgument of type . aliasTypeArguments ?? [ ] ) {
314
- visitType ( typeArgument , true ) ;
315
- }
316
-
317
317
visitType ( type . getNumberIndexType ( ) , true ) ;
318
318
visitType ( type . getStringIndexType ( ) , true ) ;
319
319
@@ -332,11 +332,6 @@ function collectTypeParameterUsageCounts(
332
332
else if ( isOperatorType ( type ) ) {
333
333
visitType ( type . type , assumeMultipleUses ) ;
334
334
}
335
-
336
- // Catch-all: generic type references like `Exclude<T, null>`
337
- else if ( type . aliasTypeArguments ) {
338
- visitTypesList ( type . aliasTypeArguments , true ) ;
339
- }
340
335
}
341
336
342
337
function incrementIdentifierCount (
0 commit comments