@@ -486,7 +486,7 @@ function createSchemaResolvers(
486
486
const visited = new Set < ts . Type > ( ) ;
487
487
488
488
function shouldIgnore ( subtype : ts . Type ) {
489
- const name = typeChecker . typeToString ( subtype ) ;
489
+ const name = getFullyQualifiedName ( subtype ) ;
490
490
if ( name === 'any' ) {
491
491
return true ;
492
492
}
@@ -531,7 +531,7 @@ function createSchemaResolvers(
531
531
text : tag . text !== undefined ? ts . displayPartsToString ( tag . text ) : undefined ,
532
532
} ) ) ,
533
533
required : ! ( prop . flags & ts . SymbolFlags . Optional ) ,
534
- type : typeChecker . typeToString ( subtype ) ,
534
+ type : getFullyQualifiedName ( subtype ) ,
535
535
rawType : rawType ? subtype : undefined ,
536
536
get declarations ( ) {
537
537
return declarations ??= getDeclarations ( prop . declarations ?? [ ] ) ;
@@ -551,7 +551,7 @@ function createSchemaResolvers(
551
551
552
552
return {
553
553
name : prop . getName ( ) ,
554
- type : typeChecker . typeToString ( subtype ) ,
554
+ type : getFullyQualifiedName ( subtype ) ,
555
555
rawType : rawType ? subtype : undefined ,
556
556
description : ts . displayPartsToString ( prop . getDocumentationComment ( typeChecker ) ) ,
557
557
get declarations ( ) {
@@ -569,7 +569,7 @@ function createSchemaResolvers(
569
569
570
570
return {
571
571
name : expose . getName ( ) ,
572
- type : typeChecker . typeToString ( subtype ) ,
572
+ type : getFullyQualifiedName ( subtype ) ,
573
573
rawType : rawType ? subtype : undefined ,
574
574
description : ts . displayPartsToString ( expose . getDocumentationComment ( typeChecker ) ) ,
575
575
get declarations ( ) {
@@ -590,13 +590,13 @@ function createSchemaResolvers(
590
590
if ( call . parameters . length >= 2 ) {
591
591
subtype = typeChecker . getTypeOfSymbolAtLocation ( call . parameters [ 1 ] , symbolNode ) ;
592
592
if ( ( call . parameters [ 1 ] . valueDeclaration as any ) ?. dotDotDotToken ) {
593
- subtypeStr = typeChecker . typeToString ( subtype ) ;
593
+ subtypeStr = getFullyQualifiedName ( subtype ) ;
594
594
getSchema = ( ) => typeChecker . getTypeArguments ( subtype ! as ts . TypeReference ) . map ( resolveSchema ) ;
595
595
}
596
596
else {
597
597
subtypeStr = '[' ;
598
598
for ( let i = 1 ; i < call . parameters . length ; i ++ ) {
599
- subtypeStr += typeChecker . typeToString ( typeChecker . getTypeOfSymbolAtLocation ( call . parameters [ i ] , symbolNode ) ) + ', ' ;
599
+ subtypeStr += getFullyQualifiedName ( typeChecker . getTypeOfSymbolAtLocation ( call . parameters [ i ] , symbolNode ) ) + ', ' ;
600
600
}
601
601
subtypeStr = subtypeStr . slice ( 0 , - 2 ) + ']' ;
602
602
getSchema = ( ) => {
@@ -643,7 +643,7 @@ function createSchemaResolvers(
643
643
} ;
644
644
}
645
645
function resolveSchema ( subtype : ts . Type ) : PropertyMetaSchema {
646
- const type = typeChecker . typeToString ( subtype ) ;
646
+ const type = getFullyQualifiedName ( subtype ) ;
647
647
648
648
if ( shouldIgnore ( subtype ) ) {
649
649
return type ;
@@ -662,7 +662,6 @@ function createSchemaResolvers(
662
662
} ;
663
663
}
664
664
665
- // @ts -ignore - typescript internal, isArrayLikeType exists
666
665
else if ( typeChecker . isArrayLikeType ( subtype ) ) {
667
666
let schema : PropertyMetaSchema [ ] ;
668
667
return {
@@ -694,6 +693,13 @@ function createSchemaResolvers(
694
693
695
694
return type ;
696
695
}
696
+ function getFullyQualifiedName ( type : ts . Type ) {
697
+ const str = typeChecker . typeToString ( type , undefined , ts . TypeFormatFlags . UseFullyQualifiedType | ts . TypeFormatFlags . NoTruncation ) ;
698
+ if ( str . includes ( 'import(' ) ) {
699
+ return str . replace ( / i m p o r t \( .* ?\) \. / g, '' ) ;
700
+ }
701
+ return str ;
702
+ }
697
703
function getDeclarations ( declaration : ts . Declaration [ ] ) {
698
704
if ( noDeclarations ) {
699
705
return [ ] ;
0 commit comments