@@ -1314,7 +1314,7 @@ export class ReflectionTransformer implements CustomTransformer {
1314
1314
}
1315
1315
}
1316
1316
1317
- if ( narrowed . name ) program . pushOp ( ReflectionOp . typeName , program . findOrAddStackEntry ( getIdentifierName ( narrowed . name ) ) ) ;
1317
+ if ( narrowed . name ) this . resolveTypeName ( getIdentifierName ( narrowed . name ) , program ) ;
1318
1318
1319
1319
const description = extractJSDocAttribute ( narrowed , 'description' ) ;
1320
1320
if ( description ) program . pushOp ( ReflectionOp . description , program . findOrAddStackEntry ( description ) ) ;
@@ -2125,7 +2125,7 @@ export class ReflectionTransformer implements CustomTransformer {
2125
2125
if ( resolved . importDeclaration ) {
2126
2126
//if explicit `import {type T}`, we do not emit an import and instead push any
2127
2127
if ( resolved . typeOnly ) {
2128
- program . pushOp ( ReflectionOp . any ) ;
2128
+ this . resolveTypeOnlyImport ( typeName , program ) ;
2129
2129
return ;
2130
2130
}
2131
2131
@@ -2206,7 +2206,7 @@ export class ReflectionTransformer implements CustomTransformer {
2206
2206
} else if ( isClassDeclaration ( declaration ) || isFunctionDeclaration ( declaration ) || isFunctionExpression ( declaration ) || isArrowFunction ( declaration ) ) {
2207
2207
//if explicit `import {type T}`, we do not emit an import and instead push any
2208
2208
if ( resolved . typeOnly ) {
2209
- program . pushOp ( ReflectionOp . any ) ;
2209
+ this . resolveTypeOnlyImport ( typeName , program ) ;
2210
2210
return ;
2211
2211
}
2212
2212
@@ -2308,6 +2308,18 @@ export class ReflectionTransformer implements CustomTransformer {
2308
2308
return declarationUser !== typeUser ;
2309
2309
}
2310
2310
2311
+ protected resolveTypeOnlyImport ( entityName : EntityName , program : CompilerProgram ) {
2312
+ program . pushOp ( ReflectionOp . any ) ;
2313
+ const typeName = ts . isIdentifier ( entityName )
2314
+ ? getIdentifierName ( entityName )
2315
+ : getIdentifierName ( entityName . right ) ;
2316
+ this . resolveTypeName ( typeName , program ) ;
2317
+ }
2318
+
2319
+ protected resolveTypeName ( typeName : string , program : CompilerProgram ) {
2320
+ program . pushOp ( ReflectionOp . typeName , program . findOrAddStackEntry ( typeName ) ) ;
2321
+ }
2322
+
2311
2323
protected resolveTypeParameter ( declaration : TypeParameterDeclaration , type : TypeReferenceNode | ExpressionWithTypeArguments , program : CompilerProgram ) {
2312
2324
//check if `type` was used in an expression. if so, we need to resolve it from runtime, otherwise we mark it as T
2313
2325
const isUsedInFunction = isFunctionLike ( declaration . parent ) ;
0 commit comments