quicktype-typescript-input 0.0.18 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,2 @@
1
1
  import { JSONSchemaSourceData } from "quicktype-core";
2
2
  export declare function schemaForTypeScriptSources(sourceFileNames: string[]): JSONSchemaSourceData;
3
- export declare function schemaForTypeScriptSources(sources: {
4
- [fileName: string]: string;
5
- }): JSONSchemaSourceData;
package/dist/index.js CHANGED
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ts = require("typescript");
4
4
  const typescript_json_schema_1 = require("@mark.probst/typescript-json-schema");
5
5
  const quicktype_core_1 = require("quicktype-core");
6
- const EncodedDefaultTypeScriptLibrary_1 = require("./EncodedDefaultTypeScriptLibrary");
7
6
  const settings = {
8
7
  required: true,
9
8
  titles: true,
@@ -16,72 +15,13 @@ const compilerOptions = {
16
15
  target: ts.ScriptTarget.ES5,
17
16
  module: ts.ModuleKind.CommonJS,
18
17
  strictNullChecks: true,
19
- typeRoots: []
18
+ typeRoots: [],
19
+ rootDir: "."
20
20
  };
21
- const libFileName = "lib.d.ts";
22
- let libSource = undefined;
23
- function getLibSource() {
24
- if (libSource === undefined) {
25
- libSource = quicktype_core_1.inflateBase64(EncodedDefaultTypeScriptLibrary_1.encodedDefaultTypeScriptLibrary);
26
- }
27
- return libSource;
28
- }
29
- class CompilerHost {
30
- constructor(_options, _sources) {
31
- this._sources = _sources;
32
- }
33
- fileExists(fileName) {
34
- if (fileName === libFileName)
35
- return true;
36
- return Object.prototype.hasOwnProperty.call(this._sources, fileName);
37
- }
38
- readFile(fileName) {
39
- if (fileName === libFileName) {
40
- return getLibSource();
41
- }
42
- return this._sources[fileName];
43
- }
44
- getSourceFile(fileName, languageVersion, _onError, _shouldCreateNewSourceFile) {
45
- const sourceText = this.readFile(fileName);
46
- return sourceText !== undefined ? ts.createSourceFile(fileName, sourceText, languageVersion) : undefined;
47
- }
48
- getDefaultLibFileName(_options) {
49
- return libFileName;
50
- }
51
- writeFile(fileName) {
52
- return quicktype_core_1.panic(`writeFile should not be called by the TypeScript compiler. Filename ${fileName}`);
53
- }
54
- getCurrentDirectory() {
55
- return ".";
56
- }
57
- getDirectories(_path) {
58
- return [];
59
- }
60
- getCanonicalFileName(fileName) {
61
- if (this.useCaseSensitiveFileNames()) {
62
- return fileName.toLowerCase();
63
- }
64
- return fileName;
65
- }
66
- useCaseSensitiveFileNames() {
67
- return false;
68
- }
69
- getNewLine() {
70
- return "\n";
71
- }
72
- }
73
- function schemaForTypeScriptSources(sources) {
74
- let fileNames;
75
- let host;
76
- if (Array.isArray(sources)) {
77
- fileNames = sources;
78
- host = ts.createCompilerHost(compilerOptions);
79
- }
80
- else {
81
- fileNames = Object.getOwnPropertyNames(sources);
82
- host = new CompilerHost(compilerOptions, sources);
83
- }
84
- const program = ts.createProgram(fileNames, compilerOptions, host);
21
+ // FIXME: We're stringifying and then parsing this schema again. Just pass around
22
+ // the schema directly.
23
+ function schemaForTypeScriptSources(sourceFileNames) {
24
+ const program = ts.createProgram(sourceFileNames, compilerOptions);
85
25
  const diagnostics = ts.getPreEmitDiagnostics(program);
86
26
  const error = diagnostics.find(d => d.category === ts.DiagnosticCategory.Error);
87
27
  if (error !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-typescript-input",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "Package for using TypeScript as an input language to quicktype",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -13,7 +13,7 @@
13
13
  "tslint": "tslint --project ."
14
14
  },
15
15
  "dependencies": {
16
- "quicktype-core": "^6.1.8",
16
+ "quicktype-core": "^6.1.10",
17
17
  "typescript": "~3.2.1",
18
18
  "@mark.probst/typescript-json-schema": "~0.32.0"
19
19
  },
@@ -25,6 +25,6 @@
25
25
  "dist/**"
26
26
  ],
27
27
  "config": {
28
- "commit": "4523ba79ed0103e4d456538e6651451422c30977"
28
+ "commit": "efb659b6ac0536d13f49385cf2affd05680bc04b"
29
29
  }
30
30
  }