@@ -7,7 +7,6 @@ import { JSONSchema7 } from "json-schema";
7
7
import { pathEqual } from "path-equal" ;
8
8
export { Program , CompilerOptions , Symbol } from "typescript" ;
9
9
10
-
11
10
const vm = require ( "vm" ) ;
12
11
13
12
const REGEX_FILE_NAME_OR_SPACE = / ( \b i m p o r t \( " .* ?" \) | " .* ?" ) \. | / g;
@@ -512,7 +511,6 @@ export class JsonSchemaGenerator {
512
511
this . inheritingTypes = inheritingTypes ;
513
512
this . tc = tc ;
514
513
this . userValidationKeywords = args . validationKeywords . reduce ( ( acc , word ) => ( { ...acc , [ word ] : true } ) , { } ) ;
515
-
516
514
}
517
515
518
516
public get ReffedDefinitions ( ) : { [ key : string ] : Definition } {
@@ -528,14 +526,14 @@ export class JsonSchemaGenerator {
528
526
}
529
527
530
528
private resetSchemaSpecificProperties ( ) {
531
- this . reffedDefinitions = { } ;
532
- this . typeIdsByName = { } ;
533
- this . typeNamesById = { } ;
534
-
535
- // restore schema overrides
536
- this . schemaOverrides . forEach ( ( value , key ) => {
537
- this . reffedDefinitions [ key ] = value ;
538
- } ) ;
529
+ this . reffedDefinitions = { } ;
530
+ this . typeIdsByName = { } ;
531
+ this . typeNamesById = { } ;
532
+
533
+ // restore schema overrides
534
+ this . schemaOverrides . forEach ( ( value , key ) => {
535
+ this . reffedDefinitions [ key ] = value ;
536
+ } ) ;
539
537
}
540
538
541
539
/**
@@ -564,7 +562,7 @@ export class JsonSchemaGenerator {
564
562
jsdocs . forEach ( ( doc ) => {
565
563
// if we have @TJS -... annotations, we have to parse them
566
564
let name = doc . name ;
567
- const originalText = doc . text ? doc . text . map ( t => t . text ) . join ( "" ) : "" ;
565
+ const originalText = doc . text ? doc . text . map ( ( t ) => t . text ) . join ( "" ) : "" ;
568
566
let text = originalText ;
569
567
// In TypeScript versions prior to 3.7, it stops parsing the annotation
570
568
// at the first non-alphanumeric character and puts the rest of the line as the
@@ -643,7 +641,6 @@ export class JsonSchemaGenerator {
643
641
fixedTypes . splice ( fixedTypes . length - 1 , 1 ) ;
644
642
} else {
645
643
definition . maxItems = targetTupleType . fixedLength ;
646
-
647
644
}
648
645
} else {
649
646
const propertyTypeString = this . tc . typeToString (
@@ -876,7 +873,8 @@ export class JsonSchemaGenerator {
876
873
if ( value !== undefined ) {
877
874
pushEnumValue ( value ) ;
878
875
} else {
879
- const def = this . getTypeDefinition ( valueType ) ;
876
+ const symbol = valueType . aliasSymbol ;
877
+ const def = this . getTypeDefinition ( valueType , undefined , undefined , symbol , symbol ) ;
880
878
if ( def . type === "undefined" ) {
881
879
if ( prop ) {
882
880
( < any > prop ) . mayBeUndefined = true ;
@@ -994,7 +992,6 @@ export class JsonSchemaGenerator {
994
992
return definition ;
995
993
}
996
994
997
-
998
995
private getClassDefinition ( clazzType : ts . Type , definition : Definition ) : Definition {
999
996
const node = clazzType . getSymbol ( ) ! . getDeclarations ( ) ! [ 0 ] ;
1000
997
@@ -1476,7 +1473,7 @@ export class JsonSchemaGenerator {
1476
1473
if ( onlyIncludeFiles === undefined ) {
1477
1474
return ! file . isDeclarationFile ;
1478
1475
}
1479
- return onlyIncludeFiles . filter ( f => pathEqual ( f , file . fileName ) ) . length > 0 ;
1476
+ return onlyIncludeFiles . filter ( ( f ) => pathEqual ( f , file . fileName ) ) . length > 0 ;
1480
1477
}
1481
1478
const files = program . getSourceFiles ( ) . filter ( includeFile ) ;
1482
1479
if ( files . length ) {
@@ -1697,7 +1694,7 @@ export async function exec(filePattern: string, fullTypeName: string, args = get
1697
1694
onlyIncludeFiles = glob . sync ( filePattern ) ;
1698
1695
program = getProgramFromFiles ( onlyIncludeFiles , {
1699
1696
strictNullChecks : args . strictNullChecks ,
1700
- esModuleInterop : args . esModuleInterop
1697
+ esModuleInterop : args . esModuleInterop ,
1701
1698
} ) ;
1702
1699
onlyIncludeFiles = onlyIncludeFiles . map ( normalizeFileName ) ;
1703
1700
}
0 commit comments