@microsoft/type2docfx 2.0.7-preview.0 → 2.0.8-dev.1307076.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.js +29 -0
- package/.husky/pre-commit +5 -0
- package/.version/PipelineAssemblyInfo.cs +3 -3
- package/.version/PipelineAssemblyInfo.h +3 -3
- package/.version/build.number.info +1 -1
- package/.version/commit.version.info +1 -1
- package/.version/numeric.fileversion.info +1 -1
- package/.version/numeric.fileversion.info.noleadingzeros +1 -1
- package/.version/numeric.packageversion.info +1 -1
- package/.version/revision.number.info +1 -1
- package/.version/semantic.fileversion.info +1 -1
- package/.version/semantic.packageversion.info +1 -1
- package/.version/versions.xml +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/common/constants.js +1 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/common/error.js +2 -2
- package/dist/common/error.js.map +1 -1
- package/dist/converters/accessor.js +3 -3
- package/dist/converters/accessor.js.map +1 -1
- package/dist/converters/base.js +94 -78
- package/dist/converters/base.js.map +1 -1
- package/dist/converters/context.js.map +1 -1
- package/dist/converters/converter.js +12 -12
- package/dist/converters/converter.js.map +1 -1
- package/dist/converters/empty.js.map +1 -1
- package/dist/converters/enum.js +1 -1
- package/dist/converters/enum.js.map +1 -1
- package/dist/converters/method.js +5 -3
- package/dist/converters/method.js.map +1 -1
- package/dist/converters/module.js +1 -1
- package/dist/converters/module.js.map +1 -1
- package/dist/converters/property.js +6 -4
- package/dist/converters/property.js.map +1 -1
- package/dist/converters/reference.js.map +1 -1
- package/dist/converters/type.js +16 -6
- package/dist/converters/type.js.map +1 -1
- package/dist/helpers/linkConvertHelper.js +4 -4
- package/dist/helpers/linkConvertHelper.js.map +1 -1
- package/dist/helpers/toSdpConvertHelper.js +40 -36
- package/dist/helpers/toSdpConvertHelper.js.map +1 -1
- package/dist/idResolver.js +26 -16
- package/dist/idResolver.js.map +1 -1
- package/dist/main.js +23 -11
- package/dist/main.js.map +1 -1
- package/dist/parser.js.map +1 -1
- package/dist/postTransformer.js +10 -8
- package/dist/postTransformer.js.map +1 -1
- package/dist/tocGenerator.js +10 -8
- package/dist/tocGenerator.js.map +1 -1
- package/dprint.json +14 -0
- package/jest.config.js +5 -5
- package/npm-shrinkwrap.json +2613 -391
- package/package.json +20 -5
- package/tasks/check.js +36 -0
- package/tsconfig.json +14 -18
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
browser: false,
|
|
4
|
+
node: true,
|
|
5
|
+
},
|
|
6
|
+
|
|
7
|
+
extends: [
|
|
8
|
+
'plugin:@typescript-eslint/recommended',
|
|
9
|
+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
10
|
+
'plugin:import/typescript',
|
|
11
|
+
'plugin:security/recommended',
|
|
12
|
+
'plugin:@eslint-community/eslint-comments/recommended',
|
|
13
|
+
],
|
|
14
|
+
parser: '@typescript-eslint/parser',
|
|
15
|
+
parserOptions: {
|
|
16
|
+
tsconfigRootDir: __dirname,
|
|
17
|
+
project: ['./tsconfig.json'],
|
|
18
|
+
},
|
|
19
|
+
plugins: ['@typescript-eslint', 'import', 'security'],
|
|
20
|
+
settings: {
|
|
21
|
+
'import/resolver': {
|
|
22
|
+
node: {
|
|
23
|
+
extensions: ['.js', '.ts'],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
ignorePatterns: ['*.test.ts'],
|
|
28
|
+
rules: {},
|
|
29
|
+
};
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
// --------------------------------------------------------------------
|
|
6
6
|
|
|
7
7
|
using System.Reflection;
|
|
8
|
-
[assembly: AssemblyVersion("1.0.
|
|
9
|
-
[assembly: AssemblyFileVersion("1.0.
|
|
10
|
-
[assembly: AssemblyInformationalVersion("1.0.
|
|
8
|
+
[assembly: AssemblyVersion("1.0.02320.250")]
|
|
9
|
+
[assembly: AssemblyFileVersion("1.0.02320.250")]
|
|
10
|
+
[assembly: AssemblyInformationalVersion("1.0.02320.250")]
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
// </auto-generated>
|
|
5
5
|
// --------------------------------------------------------------------
|
|
6
6
|
|
|
7
|
-
#define ASSEMBLY_VERSION "1.0.
|
|
8
|
-
#define ASSEMBLY_FILE_VERSION "1.0.
|
|
9
|
-
#define ASSEMBLY_INFORMATIONAL_VERSION "1.0.
|
|
7
|
+
#define ASSEMBLY_VERSION "1.0.02320.250"
|
|
8
|
+
#define ASSEMBLY_FILE_VERSION "1.0.02320.250"
|
|
9
|
+
#define ASSEMBLY_INFORMATIONAL_VERSION "1.0.02320.250"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
02320
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
922bae95
|
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.02320.250
|
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.2320.250
|
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.02320250
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
250
|
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.02320.250
|
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.02320250
|
package/.version/versions.xml
CHANGED
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,0CAA2C;AAC3C,iCAA6B;AAC7B,IAAI,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEvC,mBAAO;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,0CAA2C;AAC3C,iCAA6B;AAC7B,IAAI,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEvC,mBAAO;KACJ,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;KAC5B,WAAW,CAAC,kDAAkD,CAAC;KAC/D,QAAQ,CACP,SAAS,EACT,sCAAsC;IACpC,uCAAuC;IACvC,kCAAkC;IAClC,kIAAkI,CACrI;KACA,QAAQ,CAAC,gBAAgB,EAAE,mDAAmD,CAAC;KAC/E,MAAM,CAAC,UAAU,KAAa,EAAE,MAAc;IAC7C,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,qEAAqE,CAAC,CAAC;QACnF,mBAAO,CAAC,IAAI,EAAE,CAAC;KAChB;IAED,IAAI;QACF,IAAA,UAAG,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;KACpB;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,GAAG,YAAY,iBAAS,EAAE;YAC5B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;KACF;AACH,CAAC,CAAC;KACD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/common/constants.js
CHANGED
|
@@ -6,5 +6,5 @@ exports.yamlHeader = '### YamlMime:UniversalReference';
|
|
|
6
6
|
exports.setOfTopLevelItems = new Set(['class', 'interface', 'namespace', 'type alias']);
|
|
7
7
|
exports.langs = ['typeScript'];
|
|
8
8
|
exports.sdpYamlHeaderPrefix = '### YamlMime:TS';
|
|
9
|
-
exports.alreadyExistFilename = [
|
|
9
|
+
exports.alreadyExistFilename = ['index'];
|
|
10
10
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,aAAa,CAAC;AAChC,QAAA,UAAU,GAAG,iCAAiC,CAAC;AAC/C,QAAA,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;AAChF,QAAA,KAAK,GAAG,CAAC,YAAY,CAAC,CAAC;AACvB,QAAA,mBAAmB,GAAG,iBAAiB,CAAC;AACxC,QAAA,oBAAoB,GAAG,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,aAAa,CAAC;AAChC,QAAA,UAAU,GAAG,iCAAiC,CAAC;AAC/C,QAAA,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;AAChF,QAAA,KAAK,GAAG,CAAC,YAAY,CAAC,CAAC;AACvB,QAAA,mBAAmB,GAAG,iBAAiB,CAAC;AACxC,QAAA,oBAAoB,GAAG,CAAC,OAAO,CAAC,CAAC"}
|
package/dist/common/error.js
CHANGED
|
@@ -27,8 +27,8 @@ exports.assertNever = exports.UserError = void 0;
|
|
|
27
27
|
const Util = __importStar(require("util"));
|
|
28
28
|
class UserError extends Error {
|
|
29
29
|
constructor(message) {
|
|
30
|
-
super(
|
|
31
|
-
this.name =
|
|
30
|
+
super('[User Error]: ' + message);
|
|
31
|
+
this.name = 'UserError';
|
|
32
32
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
33
33
|
}
|
|
34
34
|
}
|
package/dist/common/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/common/error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,MAAa,SAAU,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/common/error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,MAAa,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAe;QACzB,KAAK,CAAC,gBAAgB,GAAG,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAND,8BAMC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,CAAQ;IAClC,MAAM,IAAI,KAAK,CACb,uEAAuE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CACzF,CAAC;AACJ,CAAC;AAJD,kCAIC"}
|
|
@@ -41,9 +41,9 @@ class AccessorConverter extends base_1.AbstractConverter {
|
|
|
41
41
|
content: `${node.flags && node.flags.isStatic ? 'static ' : ''}${(0, idResolver_1.typeToString)(this.extractType(signatureType)[0])} ${node.name}`,
|
|
42
42
|
return: {
|
|
43
43
|
type: this.extractType(signatureType),
|
|
44
|
-
description: this.extractReturnComment(comment)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
44
|
+
description: this.extractReturnComment(comment),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
47
|
};
|
|
48
48
|
return [model];
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessor.js","sourceRoot":"","sources":["../../src/converters/accessor.ts"],"names":[],"mappings":";;;AAEA,iCAA2C;AAC3C,8CAA6C;AAG7C,MAAa,iBAAkB,SAAQ,wBAAiB;
|
|
1
|
+
{"version":3,"file":"accessor.js","sourceRoot":"","sources":["../../src/converters/accessor.ts"],"names":[],"mappings":";;;AAEA,iCAA2C;AAC3C,8CAA6C;AAG7C,MAAa,iBAAkB,SAAQ,wBAAiB;IAC5C,QAAQ,CAAC,IAAU,EAAE,OAAgB;QAC7C,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;QAChD,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC,CAAC;QAC7C,IAAI,aAAa,CAAC;QAClB,IAAI,OAAO,CAAC;QACZ,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;gBACpC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC1C,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;aACxC;iBAAM;gBACL,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;gBACvC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;aACrC;SACF;aAAM,IAAI,IAAI,CAAC,YAAY,EAAE;YAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;gBACpC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC1C,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;aACxC;iBAAM;gBACL,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;gBACvC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;aACrC;SACF;QAED,MAAM,KAAK,GAAc;YACvB,GAAG,EAAE,GAAG;YACR,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,CAAC,YAAY,CAAC;YACrB,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;YAC9D,MAAM,EAAE;gBACN,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,IAAA,yBAAY,EAC3E,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CACnC,IAAI,IAAI,CAAC,IAAI,EAAE;gBAChB,MAAM,EAAE;oBACN,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;oBACrC,WAAW,EAAE,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;iBAChD;aACF;SACF,CAAC;QAEF,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CACF;AA7CD,8CA6CC"}
|
package/dist/converters/base.js
CHANGED
|
@@ -32,7 +32,7 @@ class AbstractConverter {
|
|
|
32
32
|
const deprecated = this.extractTextFromComment('@deprecated', comment);
|
|
33
33
|
if (deprecated != null) {
|
|
34
34
|
model.deprecated = {
|
|
35
|
-
content: deprecated
|
|
35
|
+
content: deprecated,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -63,10 +63,12 @@ class AbstractConverter {
|
|
|
63
63
|
if (inherits != null) {
|
|
64
64
|
const tokens = (0, linkConvertHelper_1.getTextAndLink)(inherits);
|
|
65
65
|
if (tokens.length === 2) {
|
|
66
|
-
model.extends = [
|
|
66
|
+
model.extends = [
|
|
67
|
+
{
|
|
67
68
|
name: tokens[0],
|
|
68
|
-
href: tokens[1]
|
|
69
|
-
}
|
|
69
|
+
href: tokens[1],
|
|
70
|
+
},
|
|
71
|
+
];
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
}
|
|
@@ -85,7 +87,7 @@ class AbstractConverter {
|
|
|
85
87
|
if (!comment.blockTags) {
|
|
86
88
|
return null;
|
|
87
89
|
}
|
|
88
|
-
const tag = comment.blockTags.find(item => {
|
|
90
|
+
const tag = comment.blockTags.find((item) => {
|
|
89
91
|
return item.tag === infoName;
|
|
90
92
|
});
|
|
91
93
|
if (!tag) {
|
|
@@ -95,9 +97,11 @@ class AbstractConverter {
|
|
|
95
97
|
}
|
|
96
98
|
getGenericType(typeParameters) {
|
|
97
99
|
if (typeParameters && typeParameters.length) {
|
|
98
|
-
let typeArgumentsList = typeParameters
|
|
100
|
+
let typeArgumentsList = typeParameters
|
|
101
|
+
.map((item) => {
|
|
99
102
|
return item.name;
|
|
100
|
-
})
|
|
103
|
+
})
|
|
104
|
+
.join(', ');
|
|
101
105
|
return '<' + typeArgumentsList + '>';
|
|
102
106
|
}
|
|
103
107
|
return '';
|
|
@@ -134,11 +138,11 @@ class AbstractConverter {
|
|
|
134
138
|
parseDescTextFromComment(comment) {
|
|
135
139
|
if (comment.blockTags) {
|
|
136
140
|
let text = null;
|
|
137
|
-
comment.blockTags.forEach(tag => {
|
|
138
|
-
if (tag.tag === '@classdesc'
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
comment.blockTags.forEach((tag) => {
|
|
142
|
+
if (tag.tag === '@classdesc' ||
|
|
143
|
+
tag.tag === '@description' ||
|
|
144
|
+
tag.tag === '@exemptedapi' ||
|
|
145
|
+
tag.tag === '@property') {
|
|
142
146
|
text = this.combineDisplayParts(tag.content);
|
|
143
147
|
return;
|
|
144
148
|
}
|
|
@@ -151,17 +155,18 @@ class AbstractConverter {
|
|
|
151
155
|
}
|
|
152
156
|
extractTagsTextFromComment(comment) {
|
|
153
157
|
if (comment && comment.blockTags) {
|
|
154
|
-
return comment.blockTags
|
|
158
|
+
return comment.blockTags
|
|
159
|
+
.map((tag) => {
|
|
155
160
|
if (tag.tag === '@see') {
|
|
156
161
|
const content = this.combineDisplayParts(tag.content);
|
|
157
162
|
if (content === '') {
|
|
158
163
|
return '';
|
|
159
164
|
}
|
|
160
|
-
if (content.startsWith(
|
|
165
|
+
if (content.startsWith('- ')) {
|
|
161
166
|
// becuase combineDisplayParts will trim content, if there exist typedoc added hyphen, the prefix space will be removed, so added back
|
|
162
167
|
const preBlankContent = ` ${content}`;
|
|
163
168
|
// typedoc will merge all @see tag, so just replace the " - " to See to make it looks like old typedoc
|
|
164
|
-
return `\n\n${preBlankContent.replace(/ - /g,
|
|
169
|
+
return `\n\n${preBlankContent.replace(/ - /g, 'See ')}`;
|
|
165
170
|
}
|
|
166
171
|
return `\n\nSee ${content}`;
|
|
167
172
|
}
|
|
@@ -180,7 +185,8 @@ class AbstractConverter {
|
|
|
180
185
|
else {
|
|
181
186
|
return '';
|
|
182
187
|
}
|
|
183
|
-
})
|
|
188
|
+
})
|
|
189
|
+
.join('');
|
|
184
190
|
}
|
|
185
191
|
return '';
|
|
186
192
|
}
|
|
@@ -192,18 +198,18 @@ class AbstractConverter {
|
|
|
192
198
|
if (type.type === 'union' && type.types && type.types.length) {
|
|
193
199
|
if (this.hasCommonPrefix(type.types)) {
|
|
194
200
|
result.push({
|
|
195
|
-
typeName: type.types[0].name.split('.')[0]
|
|
201
|
+
typeName: type.types[0].name.split('.')[0],
|
|
196
202
|
});
|
|
197
203
|
}
|
|
198
204
|
else {
|
|
199
205
|
result.push({
|
|
200
206
|
unionType: {
|
|
201
|
-
types: type.types.map(t => {
|
|
207
|
+
types: type.types.map((t) => {
|
|
202
208
|
let childType = this.extractType(t)[0];
|
|
203
209
|
childType.parentType = type.type;
|
|
204
210
|
return childType;
|
|
205
|
-
})
|
|
206
|
-
}
|
|
211
|
+
}),
|
|
212
|
+
},
|
|
207
213
|
});
|
|
208
214
|
}
|
|
209
215
|
}
|
|
@@ -212,8 +218,8 @@ class AbstractConverter {
|
|
|
212
218
|
result.push({
|
|
213
219
|
arrayType: {
|
|
214
220
|
...newType[0],
|
|
215
|
-
parentType: type.type
|
|
216
|
-
}
|
|
221
|
+
parentType: type.type,
|
|
222
|
+
},
|
|
217
223
|
});
|
|
218
224
|
}
|
|
219
225
|
else if (type.type === 'conditional') {
|
|
@@ -222,27 +228,27 @@ class AbstractConverter {
|
|
|
222
228
|
checkType: this.extractType(type.checkType)[0],
|
|
223
229
|
extendsType: this.extractType(type.extendsType)[0],
|
|
224
230
|
trueType: this.extractType(type.trueType)[0],
|
|
225
|
-
falseType: this.extractType(type.falseType)[0]
|
|
226
|
-
}
|
|
231
|
+
falseType: this.extractType(type.falseType)[0],
|
|
232
|
+
},
|
|
227
233
|
});
|
|
228
234
|
}
|
|
229
235
|
else if (type.type === 'intersection' && type.types.length) {
|
|
230
236
|
result.push({
|
|
231
237
|
intersectionType: {
|
|
232
|
-
types: type.types.map(t => {
|
|
238
|
+
types: type.types.map((t) => {
|
|
233
239
|
let childType = this.extractType(t)[0];
|
|
234
240
|
childType.parentType = type.type;
|
|
235
241
|
return childType;
|
|
236
|
-
})
|
|
237
|
-
}
|
|
242
|
+
}),
|
|
243
|
+
},
|
|
238
244
|
});
|
|
239
245
|
}
|
|
240
246
|
else if (type.type === 'typeOperator') {
|
|
241
247
|
result.push({
|
|
242
248
|
operatorType: {
|
|
243
249
|
operator: type.operator,
|
|
244
|
-
target: this.extractType(type.target)[0]
|
|
245
|
-
}
|
|
250
|
+
target: this.extractType(type.target)[0],
|
|
251
|
+
},
|
|
246
252
|
});
|
|
247
253
|
}
|
|
248
254
|
else if (type.type === 'query') {
|
|
@@ -254,7 +260,7 @@ class AbstractConverter {
|
|
|
254
260
|
* ```
|
|
255
261
|
*/
|
|
256
262
|
result.push({
|
|
257
|
-
queryType: this.extractType(type.queryType)[0]
|
|
263
|
+
queryType: this.extractType(type.queryType)[0],
|
|
258
264
|
});
|
|
259
265
|
}
|
|
260
266
|
else if (type.type === 'indexedAccess') {
|
|
@@ -268,7 +274,7 @@ class AbstractConverter {
|
|
|
268
274
|
indexedAccessType: {
|
|
269
275
|
indexType: this.extractType(type.indexType)[0],
|
|
270
276
|
objectType: this.extractType(type.objectType)[0],
|
|
271
|
-
}
|
|
277
|
+
},
|
|
272
278
|
});
|
|
273
279
|
}
|
|
274
280
|
else if (type.type === 'reflection' && type.declaration) {
|
|
@@ -279,25 +285,25 @@ class AbstractConverter {
|
|
|
279
285
|
name: signature.parameters[0].name ?? 'key',
|
|
280
286
|
key: {
|
|
281
287
|
typeName: signature.parameters[0].type.name,
|
|
282
|
-
typeId: signature.parameters[0].type.id
|
|
288
|
+
typeId: signature.parameters[0].type.id,
|
|
283
289
|
},
|
|
284
|
-
value: this.extractType(signature.type)[0]
|
|
285
|
-
}
|
|
290
|
+
value: this.extractType(signature.type)[0],
|
|
291
|
+
},
|
|
286
292
|
});
|
|
287
293
|
}
|
|
288
294
|
else if (type.declaration.signatures && type.declaration.signatures.length) {
|
|
289
295
|
result.push({
|
|
290
|
-
typeName: `${this.generateCallFunction('', this.fillParameters(type.declaration.signatures[0].parameters))} => ${(0, idResolver_1.typeToString)(this.extractType(type.declaration.signatures[0].type)[0])}
|
|
296
|
+
typeName: `${this.generateCallFunction('', this.fillParameters(type.declaration.signatures[0].parameters))} => ${(0, idResolver_1.typeToString)(this.extractType(type.declaration.signatures[0].type)[0])}`,
|
|
291
297
|
});
|
|
292
298
|
}
|
|
293
299
|
else if (type.declaration.children && type.declaration.children.length) {
|
|
294
300
|
result.push({
|
|
295
|
-
typeName: this.parseUserDefinedType(type)
|
|
301
|
+
typeName: this.parseUserDefinedType(type),
|
|
296
302
|
});
|
|
297
303
|
}
|
|
298
304
|
else {
|
|
299
305
|
result.push({
|
|
300
|
-
typeName: '{}'
|
|
306
|
+
typeName: '{}',
|
|
301
307
|
});
|
|
302
308
|
}
|
|
303
309
|
}
|
|
@@ -306,26 +312,26 @@ class AbstractConverter {
|
|
|
306
312
|
genericType: {
|
|
307
313
|
outter: {
|
|
308
314
|
typeName: type.name,
|
|
309
|
-
typeId: type.id
|
|
315
|
+
typeId: type.id,
|
|
310
316
|
},
|
|
311
|
-
inner: type.typeArguments.map(t => this.extractType(t)[0])
|
|
312
|
-
}
|
|
317
|
+
inner: type.typeArguments.map((t) => this.extractType(t)[0]),
|
|
318
|
+
},
|
|
313
319
|
});
|
|
314
320
|
}
|
|
315
321
|
else if (type.type === 'tuple' && type.elements && type.elements.length) {
|
|
316
322
|
result.push({
|
|
317
323
|
tupleType: {
|
|
318
|
-
types: type.elements.map(t => this.extractType(t)[0])
|
|
319
|
-
}
|
|
324
|
+
types: type.elements.map((t) => this.extractType(t)[0]),
|
|
325
|
+
},
|
|
320
326
|
});
|
|
321
327
|
}
|
|
322
328
|
else if (type.type === 'literal') {
|
|
323
329
|
let typeName = `${type.value}`;
|
|
324
|
-
if (typeof type.value ===
|
|
330
|
+
if (typeof type.value === 'string') {
|
|
325
331
|
typeName = `"${type.value}"`;
|
|
326
332
|
}
|
|
327
333
|
result.push({
|
|
328
|
-
typeName: typeName
|
|
334
|
+
typeName: typeName,
|
|
329
335
|
});
|
|
330
336
|
}
|
|
331
337
|
else if (type.type === 'mapped') {
|
|
@@ -336,19 +342,19 @@ class AbstractConverter {
|
|
|
336
342
|
templateType: this.extractType(type.templateType)[0],
|
|
337
343
|
nameType: this.extractType(type.nameType)[0],
|
|
338
344
|
optionalModifier: type.optionalModifier,
|
|
339
|
-
readonlyModifier: type.readonlyModifier
|
|
340
|
-
}
|
|
345
|
+
readonlyModifier: type.readonlyModifier,
|
|
346
|
+
},
|
|
341
347
|
});
|
|
342
348
|
}
|
|
343
349
|
else if (type.name) {
|
|
344
350
|
result.push({
|
|
345
351
|
typeName: type.name,
|
|
346
|
-
typeId: type.id
|
|
352
|
+
typeId: type.id,
|
|
347
353
|
});
|
|
348
354
|
}
|
|
349
355
|
else {
|
|
350
356
|
result.push({
|
|
351
|
-
typeName: 'Object'
|
|
357
|
+
typeName: 'Object',
|
|
352
358
|
});
|
|
353
359
|
}
|
|
354
360
|
return result;
|
|
@@ -359,19 +365,21 @@ class AbstractConverter {
|
|
|
359
365
|
return false;
|
|
360
366
|
}
|
|
361
367
|
const prefix = types[0].name.split('.')[0];
|
|
362
|
-
return types.find(t => !t.name || t.name.split('.')[0] !== prefix) === undefined;
|
|
368
|
+
return types.find((t) => !t.name || t.name.split('.')[0] !== prefix) === undefined;
|
|
363
369
|
}
|
|
364
370
|
return false;
|
|
365
371
|
}
|
|
366
372
|
generateCallFunction(prefix, parameters, typeParameters) {
|
|
367
373
|
if (parameters) {
|
|
368
|
-
return `${prefix}${this.getGenericType(typeParameters)}(${parameters
|
|
374
|
+
return `${prefix}${this.getGenericType(typeParameters)}(${parameters
|
|
375
|
+
.map((p) => `${p.id}${p.optional ? '?' : ''}: ${(0, idResolver_1.typeToString)(p.type[0])}`)
|
|
376
|
+
.join(', ')})`;
|
|
369
377
|
}
|
|
370
378
|
return '';
|
|
371
379
|
}
|
|
372
380
|
fillParameters(parameters) {
|
|
373
381
|
if (parameters) {
|
|
374
|
-
return parameters.map(p => {
|
|
382
|
+
return parameters.map((p) => {
|
|
375
383
|
let description = '';
|
|
376
384
|
if (p.comment) {
|
|
377
385
|
description = this.combineDisplayParts(p.comment.summary);
|
|
@@ -380,7 +388,7 @@ class AbstractConverter {
|
|
|
380
388
|
id: p.name,
|
|
381
389
|
type: this.extractType(p.type),
|
|
382
390
|
description: description,
|
|
383
|
-
optional: Boolean(p.flags && p.flags.isOptional)
|
|
391
|
+
optional: Boolean(p.flags && p.flags.isOptional),
|
|
384
392
|
};
|
|
385
393
|
});
|
|
386
394
|
}
|
|
@@ -394,20 +402,20 @@ class AbstractConverter {
|
|
|
394
402
|
return returnComment;
|
|
395
403
|
}
|
|
396
404
|
combineDisplayParts(parts) {
|
|
397
|
-
let result =
|
|
405
|
+
let result = '';
|
|
398
406
|
for (const item of parts || []) {
|
|
399
407
|
switch (item.kind) {
|
|
400
|
-
case
|
|
401
|
-
case
|
|
408
|
+
case 'text':
|
|
409
|
+
case 'code':
|
|
402
410
|
result += item.text;
|
|
403
411
|
break;
|
|
404
|
-
case
|
|
412
|
+
case 'inline-tag':
|
|
405
413
|
switch (item.tag) {
|
|
406
|
-
case
|
|
407
|
-
case
|
|
414
|
+
case '@label':
|
|
415
|
+
case '@inheritdoc': // Shouldn't happen
|
|
408
416
|
// ignore these content
|
|
409
417
|
break;
|
|
410
|
-
case
|
|
418
|
+
case '@linkcode':
|
|
411
419
|
result += `{${item.tag}`;
|
|
412
420
|
if (item.target && typeof item.target !== 'string') {
|
|
413
421
|
result += ` ${item.target}`;
|
|
@@ -417,8 +425,8 @@ class AbstractConverter {
|
|
|
417
425
|
}
|
|
418
426
|
result += '}';
|
|
419
427
|
break;
|
|
420
|
-
case
|
|
421
|
-
case
|
|
428
|
+
case '@link':
|
|
429
|
+
case '@linkplain':
|
|
422
430
|
result += `{${item.tag}`;
|
|
423
431
|
if (item.target && item.target !== item.text) {
|
|
424
432
|
result += ` ${item.target}`;
|
|
@@ -436,34 +444,38 @@ class AbstractConverter {
|
|
|
436
444
|
(0, error_1.assertNever)(item);
|
|
437
445
|
}
|
|
438
446
|
}
|
|
439
|
-
return result.trim().replace(/\r/g,
|
|
447
|
+
return result.trim().replace(/\r/g, '');
|
|
440
448
|
}
|
|
441
449
|
extractInformationFromSignature(method, node, signatureIndex) {
|
|
442
450
|
if (node.signatures[signatureIndex].comment) {
|
|
443
451
|
method.summary = this.findDescriptionInComment(node.signatures[signatureIndex].comment);
|
|
444
452
|
}
|
|
445
453
|
method.syntax.parameters = this.fillParameters(node.signatures[signatureIndex].parameters);
|
|
446
|
-
if (node.signatures[signatureIndex].type &&
|
|
454
|
+
if (node.signatures[signatureIndex].type &&
|
|
455
|
+
node.kindString !== 'Constructor' &&
|
|
456
|
+
node.signatures[signatureIndex].type.name !== 'void') {
|
|
447
457
|
method.syntax.return = {
|
|
448
458
|
type: this.extractType(node.signatures[signatureIndex].type),
|
|
449
|
-
description: this.extractReturnComment(node.signatures[signatureIndex].comment)
|
|
459
|
+
description: this.extractReturnComment(node.signatures[signatureIndex].comment),
|
|
450
460
|
};
|
|
451
461
|
}
|
|
452
462
|
// comment the exception handling for now as template doesn't support it, so CI will not be blocked.
|
|
453
463
|
/*
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
464
|
+
let exceptions;
|
|
465
|
+
if (node.signatures[signatureIndex].comment && node.signatures[signatureIndex].comment.tags) {
|
|
466
|
+
exceptions = node.signatures[signatureIndex].comment.tags.filter(tag => tag.tag === 'throws');
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (exceptions && exceptions.length) {
|
|
470
|
+
method.exceptions = exceptions.map(e => extractException(e));
|
|
471
|
+
}
|
|
472
|
+
*/
|
|
463
473
|
if (node.kindString === 'Method' || node.kindString === 'Function') {
|
|
464
474
|
const typeParameter = node.signatures[signatureIndex].typeParameter;
|
|
465
475
|
const functionBody = this.generateCallFunction(method.name, method.syntax.parameters, typeParameter);
|
|
466
|
-
const returnBody =
|
|
476
|
+
const returnBody = method.syntax.return && method.syntax.return.type.length > 0
|
|
477
|
+
? `: ${(0, idResolver_1.typeToString)(method.syntax.return.type[0])}`
|
|
478
|
+
: '';
|
|
467
479
|
method.syntax.content = `${node.flags && node.flags.isStatic ? 'static ' : ''}function ${functionBody}${returnBody}`;
|
|
468
480
|
method.type = node.kindString.toLowerCase();
|
|
469
481
|
if (node.inheritedFrom) {
|
|
@@ -479,9 +491,11 @@ class AbstractConverter {
|
|
|
479
491
|
}
|
|
480
492
|
}
|
|
481
493
|
composeMethodNameFromSignature(method, typeParameters) {
|
|
482
|
-
const parameterType = method.syntax.parameters
|
|
494
|
+
const parameterType = method.syntax.parameters
|
|
495
|
+
.map((p) => {
|
|
483
496
|
return (0, idResolver_1.typeToString)(p.type[0]);
|
|
484
|
-
})
|
|
497
|
+
})
|
|
498
|
+
.join(', ');
|
|
485
499
|
return method.name + this.getGenericType(typeParameters) + '(' + parameterType + ')';
|
|
486
500
|
}
|
|
487
501
|
parseTypeArgumentsForTypeAlias(node) {
|
|
@@ -509,7 +523,8 @@ class AbstractConverter {
|
|
|
509
523
|
if (!typeInfo.declaration || !typeInfo.declaration.children) {
|
|
510
524
|
return '';
|
|
511
525
|
}
|
|
512
|
-
let content = typeInfo.declaration.children
|
|
526
|
+
let content = typeInfo.declaration.children
|
|
527
|
+
.map((child) => {
|
|
513
528
|
let type = '';
|
|
514
529
|
let isOptional = child.flags && child.flags.isOptional;
|
|
515
530
|
let typePostFix = isOptional ? '?' : '';
|
|
@@ -520,7 +535,8 @@ class AbstractConverter {
|
|
|
520
535
|
type = `${this.generateCallFunction(`${child.name}${typePostFix}`, this.fillParameters(child.signatures[0].parameters))} => ${(0, idResolver_1.typeToString)(this.extractType(child.signatures[0].type)[0])}`;
|
|
521
536
|
}
|
|
522
537
|
return type;
|
|
523
|
-
})
|
|
538
|
+
})
|
|
539
|
+
.join(', ');
|
|
524
540
|
content = '{ ' + content + ' }';
|
|
525
541
|
return content;
|
|
526
542
|
}
|