@@ -124,6 +124,7 @@ export function convertType(
124124 if ( symbol ) {
125125 if (
126126 node . kind !== ts . SyntaxKind . TypeReference &&
127+ node . kind !== ts . SyntaxKind . ArrayType &&
127128 seenTypeSymbols . has ( symbol )
128129 ) {
129130 const typeString = context . checker . typeToString ( typeOrNode ) ;
@@ -196,6 +197,9 @@ const constructorConverter: TypeConverter<ts.ConstructorTypeNode, ts.Type> = {
196197 ReflectionKind . Constructor ,
197198 context . scope
198199 ) ;
200+ const rc = context . withScope ( reflection ) ;
201+ rc . setConvertingTypeNode ( ) ;
202+
199203 context . registerReflection ( reflection , symbol ) ;
200204 context . trigger ( ConverterEvents . CREATE_DECLARATION , reflection , node ) ;
201205
@@ -205,7 +209,7 @@ const constructorConverter: TypeConverter<ts.ConstructorTypeNode, ts.Type> = {
205209 reflection
206210 ) ;
207211 context . registerReflection ( signature , void 0 ) ;
208- const signatureCtx = context . withScope ( signature ) ;
212+ const signatureCtx = rc . withScope ( signature ) ;
209213
210214 reflection . signatures = [ signature ] ;
211215 signature . type = convertType ( signatureCtx , node . type ) ;
@@ -215,7 +219,7 @@ const constructorConverter: TypeConverter<ts.ConstructorTypeNode, ts.Type> = {
215219 node . parameters
216220 ) ;
217221 signature . typeParameters = convertTypeParameterNodes (
218- context . withScope ( reflection ) ,
222+ signatureCtx ,
219223 node . typeParameters
220224 ) ;
221225
@@ -287,6 +291,8 @@ const functionTypeConverter: TypeConverter<ts.FunctionTypeNode, ts.Type> = {
287291 ReflectionKind . TypeLiteral ,
288292 context . scope
289293 ) ;
294+ const rc = context . withScope ( reflection ) ;
295+
290296 context . registerReflection ( reflection , symbol ) ;
291297 context . trigger ( ConverterEvents . CREATE_DECLARATION , reflection , node ) ;
292298
@@ -296,7 +302,7 @@ const functionTypeConverter: TypeConverter<ts.FunctionTypeNode, ts.Type> = {
296302 reflection
297303 ) ;
298304 context . registerReflection ( signature , void 0 ) ;
299- const signatureCtx = context . withScope ( signature ) ;
305+ const signatureCtx = rc . withScope ( signature ) ;
300306
301307 reflection . signatures = [ signature ] ;
302308 signature . type = convertType ( signatureCtx , node . type ) ;
@@ -306,7 +312,7 @@ const functionTypeConverter: TypeConverter<ts.FunctionTypeNode, ts.Type> = {
306312 node . parameters
307313 ) ;
308314 signature . typeParameters = convertTypeParameterNodes (
309- context . withScope ( reflection ) ,
315+ signatureCtx ,
310316 node . typeParameters
311317 ) ;
312318
@@ -468,24 +474,23 @@ const typeLiteralConverter: TypeConverter<ts.TypeLiteralNode> = {
468474 ReflectionKind . TypeLiteral ,
469475 context . scope
470476 ) ;
477+ const rc = context . withScope ( reflection ) ;
478+ rc . setConvertingTypeNode ( ) ;
479+
471480 context . registerReflection ( reflection , symbol ) ;
472481 context . trigger ( ConverterEvents . CREATE_DECLARATION , reflection , node ) ;
473482
474483 for ( const prop of context . checker . getPropertiesOfType ( type ) ) {
475- convertSymbol ( context . withScope ( reflection ) , prop ) ;
484+ convertSymbol ( rc , prop ) ;
476485 }
477486 for ( const signature of type . getCallSignatures ( ) ) {
478487 reflection . signatures ??= [ ] ;
479488 reflection . signatures . push (
480- createSignature (
481- context . withScope ( reflection ) ,
482- ReflectionKind . CallSignature ,
483- signature
484- )
489+ createSignature ( rc , ReflectionKind . CallSignature , signature )
485490 ) ;
486491 }
487492
488- convertIndexSignature ( context . withScope ( reflection ) , symbol ) ;
493+ convertIndexSignature ( rc , symbol ) ;
489494
490495 return new ReflectionType ( reflection ) ;
491496 } ,
@@ -575,10 +580,12 @@ const referenceConverter: TypeConverter<
575580 convertType ( context , type ) {
576581 const symbol = type . aliasSymbol ?? type . getSymbol ( ) ;
577582 if ( ! symbol ) {
578- // If we get in here, the user is doing something bad. Probably using mixins.
579- const broken = new UnknownType ( context . checker . typeToString ( type ) ) ;
580- context . logger . warn ( `Bad reference type: ${ broken . name } ` ) ;
581- return broken ;
583+ // This happens when we get a reference to a type parameter
584+ // created within a mapped type, `K` in: `{ [K in T]: string }`
585+ return ReferenceType . createBrokenReference (
586+ context . checker . typeToString ( type ) ,
587+ context . project
588+ ) ;
582589 }
583590
584591 const ref = new ReferenceType (
0 commit comments