ts-json-schema-generator
Advanced tools
Comparing version 0.38.1 to 0.39.0
@@ -10,2 +10,4 @@ import * as ts from "typescript"; | ||
private allTypes; | ||
private prioritizedFiles; | ||
private unprioritizedFiles; | ||
constructor(program: ts.Program, nodeParser: NodeParser, typeFormatter: TypeFormatter); | ||
@@ -12,0 +14,0 @@ createSchema(fullName: string): Schema; |
@@ -13,2 +13,14 @@ "use strict"; | ||
this.typeFormatter = typeFormatter; | ||
this.allTypes = new Map(); | ||
const sourceFiles = this.program.getSourceFiles(); | ||
this.prioritizedFiles = []; | ||
this.unprioritizedFiles = []; | ||
for (const f of sourceFiles) { | ||
if (!f.fileName.includes("/node_modules/")) { | ||
this.prioritizedFiles.push(f); | ||
} | ||
else { | ||
this.unprioritizedFiles.push(f); | ||
} | ||
} | ||
} | ||
@@ -22,10 +34,21 @@ createSchema(fullName) { | ||
const typeChecker = this.program.getTypeChecker(); | ||
if (!this.allTypes) { | ||
this.allTypes = new Map(); | ||
this.program.getSourceFiles().forEach((sourceFile) => this.inspectNode(sourceFile, typeChecker, this.allTypes)); | ||
if (this.prioritizedFiles.length) { | ||
for (const sourceFile of this.prioritizedFiles) { | ||
this.inspectNode(sourceFile, typeChecker, this.allTypes); | ||
} | ||
this.prioritizedFiles = []; | ||
} | ||
if (!this.allTypes.has(fullName)) { | ||
throw new NoRootTypeError_1.NoRootTypeError(fullName); | ||
if (this.allTypes.has(fullName)) { | ||
return this.allTypes.get(fullName); | ||
} | ||
return this.allTypes.get(fullName); | ||
if (this.unprioritizedFiles.length) { | ||
for (const sourceFile of this.unprioritizedFiles) { | ||
this.inspectNode(sourceFile, typeChecker, this.allTypes); | ||
} | ||
this.unprioritizedFiles = []; | ||
} | ||
if (this.allTypes.has(fullName)) { | ||
return this.allTypes.get(fullName); | ||
} | ||
throw new NoRootTypeError_1.NoRootTypeError(fullName); | ||
} | ||
@@ -32,0 +55,0 @@ inspectNode(node, typeChecker, allTypes) { |
{ | ||
"name": "ts-json-schema-generator", | ||
"version": "0.38.1", | ||
"version": "0.39.0", | ||
"description": "Generate JSON schema from your Typescript sources", | ||
@@ -44,3 +44,3 @@ "main": "dist/index.js", | ||
"json-stable-stringify": "^1.0.1", | ||
"typescript": "^3.2.2" | ||
"typescript": "^3.2.4" | ||
}, | ||
@@ -54,10 +54,10 @@ "devDependencies": { | ||
"@types/node": "10.12.18", | ||
"ajv": "~6.6.2", | ||
"ajv": "~6.7.0", | ||
"chai": "~4.2.0", | ||
"jest": "^23.6.0", | ||
"jest-junit": "^5.2.0", | ||
"source-map-support": "~0.5.9", | ||
"jest": "^24.0.0", | ||
"jest-junit": "^6.1.0", | ||
"source-map-support": "~0.5.10", | ||
"ts-jest": "^23.10.5", | ||
"ts-node": "^7.0.1", | ||
"tslint": "~5.12.0" | ||
"ts-node": "^8.0.1", | ||
"tslint": "~5.12.1" | ||
}, | ||
@@ -64,0 +64,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
462777
4059
Updatedtypescript@^3.2.4