@@ -38,7 +38,7 @@ import {
3838 createSignature ,
3939} from "./factories/signature.js" ;
4040import { convertSymbol } from "./symbols.js" ;
41- import { isObjectType } from "./utils/nodes.js" ;
41+ import { isObjectType , isTypeReference } from "./utils/nodes.js" ;
4242import { removeUndefined } from "./utils/reflections.js" ;
4343import type { TranslatedString } from "../internationalization/internationalization.js" ;
4444
@@ -813,6 +813,7 @@ const referenceConverter: TypeConverter<
813813 context ,
814814 name ,
815815 ) ;
816+
816817 if ( type . flags & ts . TypeFlags . Substitution ) {
817818 // NoInfer<T>
818819 ref . typeArguments = [
@@ -823,11 +824,24 @@ const referenceConverter: TypeConverter<
823824 convertType ( context , ( type as ts . StringMappingType ) . type ) ,
824825 ] ;
825826 } else {
826- ref . typeArguments = (
827- type . aliasSymbol
828- ? type . aliasTypeArguments
829- : ( type as ts . TypeReference ) . typeArguments
830- ) ?. map ( ( ref ) => convertType ( context , ref ) ) ;
827+ // Default type arguments are filled with a reference to the default
828+ // type. As TS doesn't support specifying earlier defaults, we know
829+ // that this will only filter out type arguments which aren't specified
830+ // by the user.
831+ let ignoredArgs : ts . Type [ ] | undefined ;
832+ if ( isTypeReference ( type ) ) {
833+ ignoredArgs = type . target . typeParameters
834+ ?. map ( ( p ) => p . getDefault ( ) )
835+ . filter ( ( x ) => ! ! x ) ;
836+ }
837+
838+ const args = type . aliasSymbol
839+ ? type . aliasTypeArguments
840+ : ( type as ts . TypeReference ) . typeArguments ;
841+
842+ ref . typeArguments = args
843+ ?. filter ( ( ref ) => ! ignoredArgs ?. includes ( ref ) )
844+ . map ( ( ref ) => convertType ( context , ref ) ) ;
831845 }
832846 return ref ;
833847 } ,
0 commit comments