@@ -199,10 +199,11 @@ class TSExternsGenerator {
199199 }
200200 if (options != null ) {
201201 if (options .includedPackages != null ) {
202+ final qnameLastDotIndex = qname .lastIndexOf (" ." );
203+ final qnamePack = qnameLastDotIndex != - 1 ? qname .substr (0 , qnameLastDotIndex ).split (" ." ) : [];
202204 for (includedPackage in options .includedPackages ) {
203- if (isInPackage (includedPackage .split (" ." ), baseType . pack , false )) {
205+ if (isInPackage (includedPackage .split (" ." ), qnamePack , false )) {
204206 if (options .excludeSymbols != null ) {
205- var qname = baseTypeToQname (baseType , []);
206207 if (options .excludeSymbols .indexOf (qname ) != - 1 ) {
207208 return true ;
208209 }
@@ -214,7 +215,6 @@ class TSExternsGenerator {
214215 return true ;
215216 }
216217 } else if (options .excludeSymbols != null ) {
217- var qname = baseTypeToQname (baseType , []);
218218 if (options .excludeSymbols .indexOf (qname ) != - 1 ) {
219219 return true ;
220220 }
@@ -788,6 +788,9 @@ class TSExternsGenerator {
788788 }
789789 break ;
790790 case TType (t , params ):
791+ for (param in params ) {
792+ addMacroTypeQnamesForImport (param , qnames , pack );
793+ }
791794 var typedefType = t .get ();
792795 type = typedefType .type ;
793796 case TFun (args , ret ):
@@ -1137,20 +1140,21 @@ class TSExternsGenerator {
11371140 }
11381141
11391142 private function macroTypeToQname (type : Type , includeParams : Bool = true ): String {
1143+ var defTypeParams : Array <Type > = null ;
11401144 while (type != null ) {
11411145 switch (type ) {
11421146 case TInst (t , params ):
11431147 var classType = t .get ();
11441148 switch (classType .kind ) {
11451149 case KTypeParameter (constraints ):
1146- return baseTypeToUnqualifiedName (classType , params , includeParams );
1150+ return baseTypeToUnqualifiedName (classType , defTypeParams != null ? defTypeParams : params , includeParams );
11471151 default :
11481152 }
1149- return baseTypeToQname (classType , params , includeParams );
1153+ return baseTypeToQname (classType , defTypeParams != null ? defTypeParams : params , includeParams );
11501154 case TEnum (t , params ):
1151- return baseTypeToQname (t .get (), params , includeParams );
1155+ return baseTypeToQname (t .get (), defTypeParams != null ? defTypeParams : params , includeParams );
11521156 case TAbstract (t , params ):
1153- return abstractTypeToQname (t .get (), params , includeParams );
1157+ return abstractTypeToQname (t .get (), defTypeParams != null ? defTypeParams : params , includeParams );
11541158 case TType (t , params ):
11551159 var defType = t .get ();
11561160 if (options != null && options .renameSymbols != null ) {
@@ -1175,6 +1179,9 @@ class TSExternsGenerator {
11751179 }
11761180 }
11771181 type = t .get ().type ;
1182+ if (defTypeParams == null ) {
1183+ defTypeParams = params ;
1184+ }
11781185 case TDynamic (t ):
11791186 if (t != null ) {
11801187 var valueType = macroTypeToUnqualifiedName (t , includeParams );
@@ -1228,20 +1235,21 @@ class TSExternsGenerator {
12281235 }
12291236
12301237 private function macroTypeToUnqualifiedName (type : Type , includeParams : Bool = true ): String {
1238+ var defTypeParams : Array <Type > = null ;
12311239 while (type != null ) {
12321240 switch (type ) {
12331241 case TInst (t , params ):
12341242 var classType = t .get ();
12351243 switch (classType .kind ) {
12361244 case KTypeParameter (constraints ):
1237- return baseTypeToUnqualifiedName (classType , params , includeParams );
1245+ return baseTypeToUnqualifiedName (classType , defTypeParams != null ? defTypeParams : params , includeParams );
12381246 default :
12391247 }
1240- return baseTypeToUnqualifiedName (classType , params , includeParams );
1248+ return baseTypeToUnqualifiedName (classType , defTypeParams != null ? defTypeParams : params , includeParams );
12411249 case TEnum (t , params ):
1242- return baseTypeToUnqualifiedName (t .get (), params , includeParams );
1250+ return baseTypeToUnqualifiedName (t .get (), defTypeParams != null ? defTypeParams : params , includeParams );
12431251 case TAbstract (t , params ):
1244- return abstractTypeToUnqualifiedName (t .get (), params , includeParams );
1252+ return abstractTypeToUnqualifiedName (t .get (), defTypeParams != null ? defTypeParams : params , includeParams );
12451253 case TType (t , params ):
12461254 var defType = t .get ();
12471255 if (options != null && options .renameSymbols != null ) {
@@ -1266,6 +1274,9 @@ class TSExternsGenerator {
12661274 }
12671275 }
12681276 type = t .get ().type ;
1277+ if (defTypeParams == null ) {
1278+ defTypeParams = params ;
1279+ }
12691280 case TDynamic (t ):
12701281 if (t != null ) {
12711282 var valueType = macroTypeToUnqualifiedName (t , includeParams );
0 commit comments