dtsgenerator 3.12.1 → 3.14.0
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/.eslintrc.json +3 -37
- package/.husky/pre-commit +4 -0
- package/.nycrc +4 -17
- package/.prettierignore +1 -0
- package/README.md +24 -2
- package/config_sample/dtsgen.json +10 -0
- package/config_sample/plugins.json +25 -0
- package/dist/cli.js +14 -84
- package/dist/commandOptions.js +1 -1
- package/dist/core/astBuilder.d.ts +1 -0
- package/dist/core/astBuilder.js +13 -8
- package/dist/core/config.js +4 -2
- package/dist/core/dtsGenerator.d.ts +4 -2
- package/dist/core/dtsGenerator.js +82 -76
- package/dist/core/index.js +4 -4
- package/dist/core/jsonSchema.js +19 -7
- package/dist/core/referenceResolver.d.ts +1 -1
- package/dist/core/referenceResolver.js +6 -6
- package/dist/core/schemaId.js +1 -1
- package/dist/core/type.d.ts +2 -2
- package/dist/core/type.js +12 -12
- package/dist/core/typeTree.d.ts +6 -0
- package/dist/core/typeTree.js +34 -0
- package/dist/core/utils.d.ts +1 -1
- package/dist/core/utils.js +9 -10
- package/dist/utils.d.ts +5 -1
- package/dist/utils.js +83 -5
- package/package.json +35 -44
- package/src/cli.ts +3 -78
- package/src/commandOptions.ts +1 -1
- package/src/core/astBuilder.ts +12 -4
- package/src/core/config.ts +3 -1
- package/src/core/dtsGenerator.ts +123 -101
- package/src/core/jsonSchema.ts +26 -12
- package/src/core/referenceResolver.ts +1 -1
- package/src/core/type.ts +7 -2
- package/src/core/typeTree.ts +39 -0
- package/src/core/utils.ts +7 -9
- package/src/utils.ts +79 -2
- package/tsconfig.json +1 -1
- package/.github/FUNDING.yml +0 -3
package/.eslintrc.json
CHANGED
|
@@ -1,50 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
+
"root": true,
|
|
2
3
|
"extends": [
|
|
3
|
-
"
|
|
4
|
-
"plugin:@typescript-eslint/recommended",
|
|
5
|
-
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
|
6
|
-
"plugin:import/errors",
|
|
7
|
-
"plugin:import/warnings",
|
|
8
|
-
"plugin:import/typescript",
|
|
9
|
-
"prettier"
|
|
4
|
+
"@dtsgenerator"
|
|
10
5
|
],
|
|
11
|
-
"plugins": [
|
|
12
|
-
"sort-imports-es6-autofix"
|
|
13
|
-
],
|
|
14
|
-
"env": {
|
|
15
|
-
"node": true,
|
|
16
|
-
"es2021": true
|
|
17
|
-
},
|
|
18
|
-
"parser": "@typescript-eslint/parser",
|
|
19
|
-
"parserOptions": {
|
|
20
|
-
"project": "./tsconfig.json"
|
|
21
|
-
},
|
|
22
|
-
"settings": {
|
|
23
|
-
"import/resolver": {
|
|
24
|
-
"typescript": {
|
|
25
|
-
"alwaysTryTypes": true
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
6
|
"rules": {
|
|
30
|
-
"@typescript-eslint/no-
|
|
31
|
-
"@typescript-eslint/no-use-before-define": 0,
|
|
32
|
-
"@typescript-eslint/no-explicit-any": 0,
|
|
33
|
-
"@typescript-eslint/prefer-optional-chain": 2,
|
|
34
|
-
"@typescript-eslint/prefer-nullish-coalescing": 2,
|
|
35
|
-
"@typescript-eslint/no-floating-promises": ["error", {"ignoreIIFE": true, "ignoreVoid": true}],
|
|
36
|
-
"import/order": ["error", { "alphabetize": { "order": "asc" } }],
|
|
37
|
-
"import/no-named-as-default": 0,
|
|
38
|
-
"import/no-named-as-default-member": 0
|
|
7
|
+
"@typescript-eslint/no-explicit-any": 0
|
|
39
8
|
},
|
|
40
9
|
"overrides": [
|
|
41
10
|
{
|
|
42
11
|
"files": [
|
|
43
12
|
"**/*_test.ts"
|
|
44
13
|
],
|
|
45
|
-
"env": {
|
|
46
|
-
"mocha": true
|
|
47
|
-
},
|
|
48
14
|
"rules": {
|
|
49
15
|
"@typescript-eslint/ban-ts-comment": 0,
|
|
50
16
|
"@typescript-eslint/no-empty-interface": 0,
|
package/.nycrc
CHANGED
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
".ts"
|
|
6
|
-
],
|
|
7
|
-
"include": [
|
|
8
|
-
"**/*.ts"
|
|
9
|
-
],
|
|
2
|
+
"extends": "@istanbuljs/nyc-config-typescript",
|
|
3
|
+
"all": true,
|
|
4
|
+
"check-coverage": true,
|
|
10
5
|
"exclude": [
|
|
11
6
|
"**/*.js",
|
|
12
7
|
"coverage/**",
|
|
13
8
|
"node_modules/**",
|
|
14
9
|
"**/*.d.ts",
|
|
15
10
|
"**/*_test.ts"
|
|
16
|
-
]
|
|
17
|
-
"sourceMap": true,
|
|
18
|
-
"reporter": [
|
|
19
|
-
"html",
|
|
20
|
-
"text",
|
|
21
|
-
"text-summary"
|
|
22
|
-
],
|
|
23
|
-
"all": true,
|
|
24
|
-
"instrument": true
|
|
11
|
+
]
|
|
25
12
|
}
|
|
26
13
|
|
package/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/test/snapshots
|
package/README.md
CHANGED
|
@@ -4,10 +4,10 @@ TypeScript d.ts file generator from JSON Schema file or OpenAPI(Swagger) spec fi
|
|
|
4
4
|
|
|
5
5
|
[](#)
|
|
6
6
|
[](https://www.npmjs.com/package/dtsgenerator)
|
|
7
|
-
[](https://github.com/horiuchi/dtsgenerator/actions/workflows/workflow-ci.yaml)
|
|
8
8
|
[](https://coveralls.io/github/horiuchi/dtsgenerator?branch=master)
|
|
9
9
|
[](https://www.npmjs.com/package/dtsgenerator)
|
|
10
|
-
[](https://stakes.social/0x68c824db5A1634940BB838468Ff2aee2bDa5794B)
|
|
11
11
|
[](#)
|
|
12
12
|
|
|
13
13
|
## Table of Contents
|
|
@@ -55,6 +55,8 @@ Examples:
|
|
|
55
55
|
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
For the configuration file, please refer to the file in the [config_sample](https://github.com/horiuchi/dtsgenerator/tree/master/config_sample/) directory.
|
|
59
|
+
|
|
58
60
|
### NodeJS API
|
|
59
61
|
```js
|
|
60
62
|
const { default: dtsgenerator, parseSchema } = require('dtsgenerator');
|
|
@@ -141,6 +143,26 @@ Output debug message by [debug](https://www.npmjs.com/package/debug) library.
|
|
|
141
143
|
|
|
142
144
|
## ChangeLog
|
|
143
145
|
|
|
146
|
+
### [v3.14.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.13.2) (2022-01-27)
|
|
147
|
+
|
|
148
|
+
- features:
|
|
149
|
+
- Support the nested `allOf` and `oneOf` schema for #513. Thank you for your report @Cry0nicS :+1:
|
|
150
|
+
|
|
151
|
+
### [v3.13.2](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.13.2) (2021-10-08)
|
|
152
|
+
|
|
153
|
+
- features:
|
|
154
|
+
- Fix the type generation malformed objects with number-like keys for #523. Thank you for your report @DamianOsipiuk :+1:
|
|
155
|
+
|
|
156
|
+
### [v3.13.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.13.1) (2021-09-29)
|
|
157
|
+
|
|
158
|
+
- features:
|
|
159
|
+
- Change the plug-in interface, the PluginContext::inputSchemas to IterableIterator for #521. Thank you @djrollins :+1:
|
|
160
|
+
|
|
161
|
+
### [v3.13.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.13.0) (2021-08-31)
|
|
162
|
+
|
|
163
|
+
- features:
|
|
164
|
+
- Support new `$schema` types for #507.
|
|
165
|
+
|
|
144
166
|
### [v3.12.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.12.1) (2021-05-19)
|
|
145
167
|
|
|
146
168
|
- fixed:
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"input": {
|
|
3
|
+
"files": ["./schema.json", "./schema/additional.yaml"],
|
|
4
|
+
"urls": ["http://www.example.com/schema.json"],
|
|
5
|
+
"stdin": false
|
|
6
|
+
},
|
|
7
|
+
"target": "es2020",
|
|
8
|
+
"outputAST": false,
|
|
9
|
+
"outputFile": "./types.d.ts",
|
|
10
|
+
"plugins": {
|
|
11
|
+
"@dtsgenerator/single-quote": true,
|
|
12
|
+
"@dtsgenerator/replace-namespace": {
|
|
13
|
+
"map": [
|
|
14
|
+
{
|
|
15
|
+
"from": ["Components", "Schemas"],
|
|
16
|
+
"to": ["Test", "PetStore"]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"from": ["Paths"],
|
|
20
|
+
"to": ["Test", "PetStore"]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -1,97 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
4
|
+
const fs = (0, tslib_1.__importStar)(require("fs"));
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
function readConfig(options) {
|
|
11
|
-
var _a;
|
|
12
|
-
let pc = {};
|
|
13
|
-
const configFile = (_a = options.configFile) !== null && _a !== void 0 ? _a : commandOptions_1.defaultConfigFile;
|
|
14
|
-
try {
|
|
15
|
-
pc = loadJSON(configFile);
|
|
16
|
-
pc.configFile = configFile;
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
if (options.configFile != null) {
|
|
20
|
-
console.error('Error to load config file from ' + options.configFile);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (pc.input == null) {
|
|
24
|
-
pc.input = {
|
|
25
|
-
files: [],
|
|
26
|
-
urls: [],
|
|
27
|
-
stdin: false,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
if (options.files.length > 0) {
|
|
31
|
-
pc.input.files = options.files;
|
|
32
|
-
}
|
|
33
|
-
else if (pc.input.files == null) {
|
|
34
|
-
pc.input.files = [];
|
|
35
|
-
}
|
|
36
|
-
if (options.urls.length > 0) {
|
|
37
|
-
pc.input.urls = options.urls;
|
|
38
|
-
}
|
|
39
|
-
else if (pc.input.urls == null) {
|
|
40
|
-
pc.input.urls = [];
|
|
41
|
-
}
|
|
42
|
-
pc.input.stdin = options.isReadFromStdin();
|
|
43
|
-
if (options.out != null) {
|
|
44
|
-
pc.outputFile = options.out;
|
|
45
|
-
}
|
|
46
|
-
if (options.target != null) {
|
|
47
|
-
pc.target = convertToScriptTarget(options.target);
|
|
48
|
-
}
|
|
49
|
-
pc.outputAST = !!options.outputAST;
|
|
50
|
-
return pc;
|
|
51
|
-
}
|
|
52
|
-
function loadJSON(file) {
|
|
53
|
-
const content = fs.readFileSync(file, 'utf-8');
|
|
54
|
-
return JSON.parse(content);
|
|
55
|
-
}
|
|
56
|
-
function convertToScriptTarget(target) {
|
|
57
|
-
switch (target.trim().toLowerCase()) {
|
|
58
|
-
case 'es3':
|
|
59
|
-
return typescript_1.ScriptTarget.ES3;
|
|
60
|
-
case 'es5':
|
|
61
|
-
return typescript_1.ScriptTarget.ES5;
|
|
62
|
-
case 'es2015':
|
|
63
|
-
return typescript_1.ScriptTarget.ES2015;
|
|
64
|
-
case 'es2016':
|
|
65
|
-
return typescript_1.ScriptTarget.ES2016;
|
|
66
|
-
case 'es2017':
|
|
67
|
-
return typescript_1.ScriptTarget.ES2017;
|
|
68
|
-
case 'es2018':
|
|
69
|
-
return typescript_1.ScriptTarget.ES2018;
|
|
70
|
-
case 'es2019':
|
|
71
|
-
return typescript_1.ScriptTarget.ES2019;
|
|
72
|
-
case 'es2020':
|
|
73
|
-
return typescript_1.ScriptTarget.ES2020;
|
|
74
|
-
case 'esnext':
|
|
75
|
-
return typescript_1.ScriptTarget.ESNext;
|
|
76
|
-
default:
|
|
77
|
-
return typescript_1.ScriptTarget.Latest;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
6
|
+
const commandOptions_1 = (0, tslib_1.__importStar)(require("./commandOptions"));
|
|
7
|
+
const core_1 = (0, tslib_1.__importStar)(require("./core"));
|
|
8
|
+
const config_1 = (0, tslib_1.__importStar)(require("./core/config"));
|
|
9
|
+
const utils_1 = require("./utils");
|
|
80
10
|
async function loadContents() {
|
|
81
11
|
let contents = [];
|
|
82
12
|
const ps = [];
|
|
83
13
|
if (config_1.default.input.stdin) {
|
|
84
|
-
ps.push(core_1.readSchemaFromStdin().then((s) => {
|
|
14
|
+
ps.push((0, core_1.readSchemaFromStdin)().then((s) => {
|
|
85
15
|
contents.push(s);
|
|
86
16
|
}));
|
|
87
17
|
}
|
|
88
18
|
for (const pattern of config_1.default.input.files) {
|
|
89
|
-
ps.push(core_1.readSchemasFromFile(pattern).then((ss) => {
|
|
19
|
+
ps.push((0, core_1.readSchemasFromFile)(pattern).then((ss) => {
|
|
90
20
|
contents = contents.concat(ss);
|
|
91
21
|
}));
|
|
92
22
|
}
|
|
93
23
|
for (const url of config_1.default.input.urls) {
|
|
94
|
-
ps.push(core_1.readSchemaFromUrl(url).then((s) => {
|
|
24
|
+
ps.push((0, core_1.readSchemaFromUrl)(url).then((s) => {
|
|
95
25
|
contents.push(s);
|
|
96
26
|
}));
|
|
97
27
|
}
|
|
@@ -99,20 +29,20 @@ async function loadContents() {
|
|
|
99
29
|
return contents;
|
|
100
30
|
}
|
|
101
31
|
async function exec() {
|
|
102
|
-
const command = commandOptions_1.initialize(process.argv);
|
|
103
|
-
const pc = readConfig(commandOptions_1.default);
|
|
104
|
-
config_1.setConfig(pc);
|
|
32
|
+
const command = (0, commandOptions_1.initialize)(process.argv);
|
|
33
|
+
const pc = (0, utils_1.readConfig)(commandOptions_1.default);
|
|
34
|
+
(0, config_1.setConfig)(pc);
|
|
105
35
|
if (commandOptions_1.default.info) {
|
|
106
36
|
const version = command.opts().version;
|
|
107
|
-
await config_1.showConfig(version, config_1.default);
|
|
37
|
+
await (0, config_1.showConfig)(version, config_1.default);
|
|
108
38
|
return;
|
|
109
39
|
}
|
|
110
40
|
const contents = await loadContents();
|
|
111
|
-
const result = await core_1.default({
|
|
41
|
+
const result = await (0, core_1.default)({
|
|
112
42
|
contents,
|
|
113
43
|
});
|
|
114
44
|
if (commandOptions_1.default.out) {
|
|
115
|
-
fs.mkdirSync(path_1.dirname(commandOptions_1.default.out), { recursive: true });
|
|
45
|
+
fs.mkdirSync((0, path_1.dirname)(commandOptions_1.default.out), { recursive: true });
|
|
116
46
|
fs.writeFileSync(commandOptions_1.default.out, result, { encoding: 'utf-8' });
|
|
117
47
|
}
|
|
118
48
|
else {
|
package/dist/commandOptions.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.clear = exports.initialize = exports.CommandOptions = exports.defaultConfigFile = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const commander = tslib_1.__importStar(require("commander"));
|
|
5
|
+
const commander = (0, tslib_1.__importStar)(require("commander"));
|
|
6
6
|
exports.defaultConfigFile = 'dtsgen.json';
|
|
7
7
|
class CommandOptions {
|
|
8
8
|
constructor() {
|
|
@@ -21,6 +21,7 @@ export declare function buildIndexSignatureNode(name: string, indexType: ts.Type
|
|
|
21
21
|
export declare function buildTypeLiteralNode(elements: ts.TypeElement[]): ts.TypeNode;
|
|
22
22
|
export declare function buildFreeFormObjectTypeLiteralNode(): ts.TypeNode;
|
|
23
23
|
export declare function buildUnionTypeNode<T>(types: T[], builder: (t: T, index: number) => ts.TypeNode, terminate: boolean): ts.TypeNode;
|
|
24
|
+
export declare function buildIntersectionTypeNode(types: readonly ts.TypeNode[], terminate: boolean): ts.TypeNode;
|
|
24
25
|
export declare function buildTupleTypeNode(types: ts.TypeNode | ts.TypeNode[], minItems?: number, maxItems?: number, additionalItems?: ts.TypeNode | false): ts.TypeNode;
|
|
25
26
|
export declare function buildTypeReferenceNode(schema: NormalizedSchema, currentSchema: Schema): ts.TypeReferenceNode;
|
|
26
27
|
export declare function addComment<T extends ts.Node>(node: T, schema: NormalizedSchema, terminate: boolean): T;
|
package/dist/core/astBuilder.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addOptionalInformation = exports.addComment = exports.buildTypeReferenceNode = exports.buildTupleTypeNode = exports.buildUnionTypeNode = exports.buildFreeFormObjectTypeLiteralNode = exports.buildTypeLiteralNode = exports.buildIndexSignatureNode = exports.buildPropertySignature = exports.buildTypeAliasNode = exports.buildInterfaceNode = exports.buildNamespaceNode = exports.buildBooleanLiteralTypeNode = exports.buildNumericLiteralTypeNode = exports.buildStringLiteralTypeNode = exports.buildNullKeyword = exports.buildSimpleArrayNode = exports.buildStringKeyword = exports.buildVoidKeyword = exports.buildUnknownKeyword = exports.buildNeverKeyword = exports.buildAnyKeyword = exports.buildKeyword = void 0;
|
|
3
|
+
exports.addOptionalInformation = exports.addComment = exports.buildTypeReferenceNode = exports.buildTupleTypeNode = exports.buildIntersectionTypeNode = exports.buildUnionTypeNode = exports.buildFreeFormObjectTypeLiteralNode = exports.buildTypeLiteralNode = exports.buildIndexSignatureNode = exports.buildPropertySignature = exports.buildTypeAliasNode = exports.buildInterfaceNode = exports.buildNamespaceNode = exports.buildBooleanLiteralTypeNode = exports.buildNumericLiteralTypeNode = exports.buildStringLiteralTypeNode = exports.buildNullKeyword = exports.buildSimpleArrayNode = exports.buildStringKeyword = exports.buildVoidKeyword = exports.buildUnknownKeyword = exports.buildNeverKeyword = exports.buildAnyKeyword = exports.buildKeyword = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const ts = tslib_1.__importStar(require("typescript"));
|
|
6
|
-
const config_1 = tslib_1.__importDefault(require("./config"));
|
|
5
|
+
const ts = (0, tslib_1.__importStar)(require("typescript"));
|
|
6
|
+
const config_1 = (0, tslib_1.__importDefault)(require("./config"));
|
|
7
7
|
const validateIdentifier_1 = require("./validateIdentifier");
|
|
8
8
|
function buildTypeNameIdentifier(name) {
|
|
9
|
-
return ts.factory.createIdentifier(validateIdentifier_1.toValidIdentifier(name, config_1.default.target));
|
|
9
|
+
return ts.factory.createIdentifier((0, validateIdentifier_1.toValidIdentifier)(name, config_1.default.target));
|
|
10
10
|
}
|
|
11
11
|
function buildPropertyNameIdentifier(name) {
|
|
12
|
-
if (
|
|
13
|
-
name = '$' + name;
|
|
14
|
-
}
|
|
15
|
-
if (validateIdentifier_1.checkInvalidCharacter(name, config_1.default.target)) {
|
|
12
|
+
if ((0, validateIdentifier_1.checkInvalidCharacter)(name, config_1.default.target)) {
|
|
16
13
|
return ts.factory.createIdentifier(name);
|
|
17
14
|
}
|
|
18
15
|
else {
|
|
@@ -125,6 +122,14 @@ function buildUnionTypeNode(types, builder, terminate) {
|
|
|
125
122
|
return ts.factory.createParenthesizedType(node);
|
|
126
123
|
}
|
|
127
124
|
exports.buildUnionTypeNode = buildUnionTypeNode;
|
|
125
|
+
function buildIntersectionTypeNode(types, terminate) {
|
|
126
|
+
const node = ts.factory.createIntersectionTypeNode(types);
|
|
127
|
+
if (terminate) {
|
|
128
|
+
return node;
|
|
129
|
+
}
|
|
130
|
+
return ts.factory.createParenthesizedType(node);
|
|
131
|
+
}
|
|
132
|
+
exports.buildIntersectionTypeNode = buildIntersectionTypeNode;
|
|
128
133
|
function buildTupleTypeNode(types, minItems, maxItems, additionalItems) {
|
|
129
134
|
function typesIsArray(types) {
|
|
130
135
|
return Array.isArray(types);
|
package/dist/core/config.js
CHANGED
|
@@ -4,13 +4,15 @@ exports.showConfig = exports.clearToDefault = exports.setConfig = void 0;
|
|
|
4
4
|
const typescript_1 = require("typescript");
|
|
5
5
|
const type_1 = require("./type");
|
|
6
6
|
const defaultConfig = {
|
|
7
|
+
configFile: undefined,
|
|
7
8
|
input: {
|
|
8
9
|
files: [],
|
|
9
10
|
urls: [],
|
|
10
11
|
stdin: false,
|
|
11
12
|
},
|
|
12
|
-
|
|
13
|
+
outputFile: undefined,
|
|
13
14
|
target: typescript_1.ScriptTarget.Latest,
|
|
15
|
+
outputAST: false,
|
|
14
16
|
plugins: {},
|
|
15
17
|
};
|
|
16
18
|
let config = Object.assign({}, defaultConfig);
|
|
@@ -52,7 +54,7 @@ async function showConfig(version, c) {
|
|
|
52
54
|
console.log();
|
|
53
55
|
const plugins = [];
|
|
54
56
|
for (const [name, option] of Object.entries(c.plugins)) {
|
|
55
|
-
const p = await type_1.loadPlugin(name, option);
|
|
57
|
+
const p = await (0, type_1.loadPlugin)(name, option);
|
|
56
58
|
if (p != null) {
|
|
57
59
|
plugins.push(p);
|
|
58
60
|
}
|
|
@@ -5,12 +5,12 @@ export default class DtsGenerator {
|
|
|
5
5
|
private contents;
|
|
6
6
|
constructor(contents: Schema[]);
|
|
7
7
|
generate(): Promise<string>;
|
|
8
|
-
private buildSchemaMergedMap;
|
|
9
8
|
private getPlugins;
|
|
10
9
|
private getPreProcess;
|
|
11
10
|
private getPostProcess;
|
|
12
11
|
private walk;
|
|
13
12
|
private walkSchema;
|
|
13
|
+
private parseSchema;
|
|
14
14
|
private normalizeContent;
|
|
15
15
|
private normalizeSchemaContent;
|
|
16
16
|
private generateDeclareType;
|
|
@@ -18,8 +18,10 @@ export default class DtsGenerator {
|
|
|
18
18
|
private generateTypeCollection;
|
|
19
19
|
private generateProperties;
|
|
20
20
|
private generateTypeProperty;
|
|
21
|
+
private generateLiteralTypeProperty;
|
|
22
|
+
private checkExistOtherType;
|
|
21
23
|
private generateLiteralTypeNode;
|
|
22
|
-
private
|
|
24
|
+
private generateUnionType;
|
|
23
25
|
private generateArrayTypeProperty;
|
|
24
26
|
private generateType;
|
|
25
27
|
private generateTypeName;
|