versioned-d.ts-tools 0.1.0 → 0.2.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/README.md +51 -2
- package/dist/dts-utilities.d.ts +41 -41
- package/dist/dts-utilities.js +332 -305
- package/dist/dts-utilities.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/version-remover.d.ts +2 -2
- package/dist/version-remover.js +186 -96
- package/dist/version-remover.js.map +1 -1
- package/dist/whats-new.d.ts +2 -2
- package/dist/whats-new.js +77 -55
- package/dist/whats-new.js.map +1 -1
- package/package.json +17 -6
package/dist/dts-utilities.js
CHANGED
|
@@ -1,306 +1,333 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
if (
|
|
4
|
-
var
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.APISet = void 0;
|
|
37
|
+
exports.parseDTS = parseDTS;
|
|
38
|
+
const ts = __importStar(require("typescript"));
|
|
39
|
+
// capturing these because of eccentricities with the compiler ordering
|
|
40
|
+
let topClass = null;
|
|
41
|
+
let lastItem = null;
|
|
42
|
+
var ClassType;
|
|
43
|
+
(function (ClassType) {
|
|
44
|
+
ClassType["Class"] = "Class";
|
|
45
|
+
ClassType["Interface"] = "Interface";
|
|
46
|
+
ClassType["Enum"] = "Enum";
|
|
47
|
+
})(ClassType || (ClassType = {}));
|
|
48
|
+
var FieldType;
|
|
49
|
+
(function (FieldType) {
|
|
50
|
+
FieldType["Property"] = "Property";
|
|
51
|
+
FieldType["Method"] = "Method";
|
|
52
|
+
FieldType["Event"] = "Event";
|
|
53
|
+
FieldType["Enum"] = "Enum";
|
|
54
|
+
})(FieldType || (FieldType = {}));
|
|
55
|
+
class FieldStruct {
|
|
56
|
+
constructor(decString, commentString, fieldType, fieldName) {
|
|
57
|
+
this.declarationString = decString;
|
|
58
|
+
this.comment = commentString;
|
|
59
|
+
this.type = fieldType;
|
|
60
|
+
this.name = fieldName;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class ClassStruct {
|
|
64
|
+
constructor(decString, commentString, classType) {
|
|
65
|
+
this.declarationString = decString;
|
|
66
|
+
this.comment = commentString;
|
|
67
|
+
this.type = classType;
|
|
68
|
+
this.fields = [];
|
|
69
|
+
}
|
|
70
|
+
copyWithoutFields() {
|
|
71
|
+
return new ClassStruct(this.declarationString, this.comment, this.type);
|
|
72
|
+
}
|
|
73
|
+
sortFields() {
|
|
74
|
+
this.fields.sort((a, b) => {
|
|
75
|
+
if (a.declarationString === b.declarationString) {
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return a.declarationString.replace("readonly ", "") < b.declarationString.replace("readonly ", "") ? -1 : 1;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
getClassName() {
|
|
84
|
+
return this.declarationString.substring(this.declarationString.lastIndexOf(" ") + 1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
class APISet {
|
|
88
|
+
constructor() {
|
|
89
|
+
this.api = [];
|
|
90
|
+
}
|
|
91
|
+
addClass(clas) {
|
|
92
|
+
this.api.push(clas);
|
|
93
|
+
}
|
|
94
|
+
containsClass(clas) {
|
|
95
|
+
let found = false;
|
|
96
|
+
this.api.forEach((element) => {
|
|
97
|
+
if (element.declarationString === clas.declarationString) {
|
|
98
|
+
found = true;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return found;
|
|
102
|
+
}
|
|
103
|
+
containsField(clas, field) {
|
|
104
|
+
let found = false;
|
|
105
|
+
this.api.forEach((element) => {
|
|
106
|
+
if (element.declarationString === clas.declarationString) {
|
|
107
|
+
element.fields.forEach((thisField) => {
|
|
108
|
+
if (thisField.declarationString === field.declarationString) {
|
|
109
|
+
found = true;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return found;
|
|
115
|
+
}
|
|
116
|
+
// finds the new fields and classes
|
|
117
|
+
diff(other) {
|
|
118
|
+
const diffAPI = new APISet();
|
|
119
|
+
this.api.forEach((element) => {
|
|
120
|
+
if (other.containsClass(element)) {
|
|
121
|
+
let classShell = null;
|
|
122
|
+
element.fields.forEach((field) => {
|
|
123
|
+
if (!other.containsField(element, field)) {
|
|
124
|
+
if (classShell === null) {
|
|
125
|
+
classShell = element.copyWithoutFields();
|
|
126
|
+
diffAPI.addClass(classShell);
|
|
127
|
+
}
|
|
128
|
+
classShell.fields.push(field);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
diffAPI.addClass(element);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return diffAPI;
|
|
137
|
+
}
|
|
138
|
+
getAsDTS() {
|
|
139
|
+
this.sort();
|
|
140
|
+
const output = [];
|
|
141
|
+
this.api.forEach((clas) => {
|
|
142
|
+
output.push(clas.comment.trim());
|
|
143
|
+
output.push(clas.declarationString + " {");
|
|
144
|
+
clas.fields.forEach((field) => {
|
|
145
|
+
output.push(" " + field.comment);
|
|
146
|
+
if (field.type === FieldType.Enum) {
|
|
147
|
+
output.push(" " + field.declarationString + ",");
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
output.push(" " + field.declarationString);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
output.push("}");
|
|
154
|
+
});
|
|
155
|
+
return output.join("\n");
|
|
156
|
+
}
|
|
157
|
+
getAsMarkdown(relativePath) {
|
|
158
|
+
this.sort();
|
|
159
|
+
// table header
|
|
160
|
+
let output = "| Class | Fields | Description |\n|:---|:---|:---|\n";
|
|
161
|
+
this.api.forEach((clas) => {
|
|
162
|
+
// Ignore the following:
|
|
163
|
+
// - Enums.
|
|
164
|
+
// - LoadOptions interfaces
|
|
165
|
+
// - *Data classes for set/load methods
|
|
166
|
+
if (clas.type !== ClassType.Enum &&
|
|
167
|
+
!clas.getClassName().endsWith("LoadOptions") &&
|
|
168
|
+
!clas.getClassName().endsWith("Data")) {
|
|
169
|
+
const className = clas.getClassName();
|
|
170
|
+
output += "|[" + className + "](/"
|
|
171
|
+
+ relativePath + className.toLowerCase() + ")|";
|
|
172
|
+
// Ignore the following:
|
|
173
|
+
// - String literal overloads.
|
|
174
|
+
// - `load`, `set`, `track`, `untrack`, and `toJSON` methods
|
|
175
|
+
// - The `context` property.
|
|
176
|
+
// - Static fields.
|
|
177
|
+
let filteredFields = clas.fields.filter((field) => {
|
|
178
|
+
let isLiteral = field.declarationString.search(/([a-zA-Z]+)(\??:)([\n]?([ |]*\"[\w]*\"[|,\n]*)+?)([ ]*[\),])/g) >= 0;
|
|
179
|
+
return (!isLiteral &&
|
|
180
|
+
field.name !== "load" &&
|
|
181
|
+
field.name !== "set" &&
|
|
182
|
+
field.name !== "toJSON" &&
|
|
183
|
+
field.name !== "context" &&
|
|
184
|
+
field.name !== "track" &&
|
|
185
|
+
field.name !== "untrack" &&
|
|
186
|
+
!field.declarationString.includes("static "));
|
|
187
|
+
});
|
|
188
|
+
let first = true;
|
|
189
|
+
if (filteredFields.length > 0) {
|
|
190
|
+
filteredFields.forEach((field) => {
|
|
191
|
+
if (first) {
|
|
192
|
+
first = false;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
output += "||";
|
|
196
|
+
}
|
|
197
|
+
// remove unnecessary parts of the declaration string
|
|
198
|
+
let newItemText = field.declarationString.replace(/;/g, "");
|
|
199
|
+
if (field.type === FieldType.Property) {
|
|
200
|
+
// Remove the optional modifier and type.
|
|
201
|
+
newItemText = newItemText.replace(/\?/g, "");
|
|
202
|
+
newItemText = newItemText.substring(0, newItemText.indexOf(":"));
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
// Remove the return type.
|
|
206
|
+
newItemText = newItemText.substring(0, newItemText.lastIndexOf(":"));
|
|
207
|
+
}
|
|
208
|
+
newItemText = newItemText.replace("readonly ", "");
|
|
209
|
+
newItemText = newItemText.replace(/\|/g, "\\|").replace(/\n|\t/gm, "");
|
|
210
|
+
newItemText = newItemText.replace(/[\s][\s]+/g, " ").replace(/\( /g, "(").replace(/ \)/g, ")").replace(/,\)/g, ")").replace(/([\w]\??: )\\\| /g, "$1"); // dprint formatting quirks
|
|
211
|
+
newItemText = newItemText.replace(/\<any\>/g, "");
|
|
212
|
+
let tableLine = "[" + newItemText + "]("
|
|
213
|
+
+ buildFieldLink(relativePath, className, field) + ")|";
|
|
214
|
+
tableLine += removeAtLink(extractFirstSentenceFromComment(field.comment));
|
|
215
|
+
output += tableLine + "|\n";
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
output += "||\n";
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
return output;
|
|
224
|
+
}
|
|
225
|
+
sort() {
|
|
226
|
+
this.api.forEach((element) => {
|
|
227
|
+
element.sortFields();
|
|
228
|
+
});
|
|
229
|
+
this.api.sort((a, b) => {
|
|
230
|
+
if (a.getClassName() === b.getClassName()) {
|
|
231
|
+
return 0;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
return a.getClassName() < b.getClassName() ? -1 : 1;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
exports.APISet = APISet;
|
|
240
|
+
function extractFirstSentenceFromComment(commentText) {
|
|
241
|
+
const firstSentenceIndex = commentText.indexOf("* ") + 2;
|
|
242
|
+
const multiSentenceEndIndex = commentText.indexOf(". ", firstSentenceIndex);
|
|
243
|
+
const lineBreakEndIndex = commentText.indexOf("\n", firstSentenceIndex);
|
|
244
|
+
const singleLineEndIndex = commentText.indexOf("\*/", firstSentenceIndex);
|
|
245
|
+
let endIndex;
|
|
246
|
+
if (multiSentenceEndIndex > 0 && lineBreakEndIndex > 0) {
|
|
247
|
+
endIndex = Math.min(multiSentenceEndIndex + 1, lineBreakEndIndex);
|
|
248
|
+
}
|
|
249
|
+
else if (multiSentenceEndIndex === -1 && lineBreakEndIndex === -1) {
|
|
250
|
+
endIndex = singleLineEndIndex;
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
endIndex = Math.max(multiSentenceEndIndex + 1, lineBreakEndIndex);
|
|
254
|
+
}
|
|
255
|
+
return commentText.substring(firstSentenceIndex, endIndex).trim();
|
|
256
|
+
}
|
|
257
|
+
function removeAtLink(commentText) {
|
|
258
|
+
// Replace links with the format "{@link Foo}" with "Foo".
|
|
259
|
+
commentText = commentText.replace(/{@link ([^|]*?)}/gm, "$1");
|
|
260
|
+
// Replace links with the format "{@link Foo | URL}" with "[Foo](URL)".
|
|
261
|
+
commentText = commentText.replace(/{@link ([^}]*?) \| (http.*?)}/gm, "[$1]($2)");
|
|
262
|
+
return commentText;
|
|
263
|
+
}
|
|
264
|
+
function buildFieldLink(relativePath, className, field) {
|
|
265
|
+
// Build the standard link anchor format based on host.
|
|
266
|
+
let anchorPrefix = relativePath.substring(relativePath.lastIndexOf("/") + 1, relativePath.lastIndexOf("."));
|
|
267
|
+
anchorPrefix = (relativePath.indexOf("outlook") > 0 ? "outlook" : anchorPrefix) + "-" + anchorPrefix + "-";
|
|
268
|
+
let fieldLink = "/" + relativePath.replace("api/outlook/outlook", "api/outlook/office") + className.toLowerCase() + "#" + anchorPrefix + className.toLowerCase() + "-" + field.name.toLowerCase() + (field.type === FieldType.Method ? "-member(1)" : "-member");
|
|
269
|
+
return fieldLink;
|
|
270
|
+
}
|
|
271
|
+
function parseDTS(fileName, fileContents) {
|
|
272
|
+
const node = ts.createSourceFile(fileName, fileContents, ts.ScriptTarget.ES2015, true);
|
|
273
|
+
const allClasses = new APISet();
|
|
274
|
+
parseDTSInternal(node, allClasses);
|
|
275
|
+
return allClasses;
|
|
276
|
+
}
|
|
277
|
+
function parseDTSInternal(node, allClasses) {
|
|
278
|
+
switch (node.kind) {
|
|
279
|
+
case ts.SyntaxKind.InterfaceDeclaration:
|
|
280
|
+
parseDTSTopLevelItem(node, allClasses, ClassType.Interface);
|
|
281
|
+
break;
|
|
282
|
+
case ts.SyntaxKind.ClassDeclaration:
|
|
283
|
+
parseDTSTopLevelItem(node, allClasses, ClassType.Class);
|
|
284
|
+
break;
|
|
285
|
+
case ts.SyntaxKind.EnumDeclaration:
|
|
286
|
+
parseDTSTopLevelItem(node, allClasses, ClassType.Enum);
|
|
287
|
+
break;
|
|
288
|
+
case ts.SyntaxKind.PropertySignature:
|
|
289
|
+
parseDTSFieldItem(node, FieldType.Property);
|
|
290
|
+
break;
|
|
291
|
+
case ts.SyntaxKind.PropertyDeclaration:
|
|
292
|
+
parseDTSFieldItem(node, FieldType.Property);
|
|
293
|
+
break;
|
|
294
|
+
case ts.SyntaxKind.EnumMember:
|
|
295
|
+
parseDTSFieldItem(node, FieldType.Enum);
|
|
296
|
+
break;
|
|
297
|
+
case ts.SyntaxKind.MethodSignature:
|
|
298
|
+
parseDTSFieldItem(node, FieldType.Method);
|
|
299
|
+
break;
|
|
300
|
+
case ts.SyntaxKind.MethodDeclaration:
|
|
301
|
+
parseDTSFieldItem(node, FieldType.Method);
|
|
302
|
+
break;
|
|
303
|
+
case ts.SyntaxKind.TypeLiteral:
|
|
304
|
+
return;
|
|
305
|
+
default:
|
|
306
|
+
// the compiler parses comments after the class/field, therefore this connects to the previous item
|
|
307
|
+
if (node.getText().indexOf("/**") >= 0 &&
|
|
308
|
+
node.getText().indexOf("*/") >= 0 &&
|
|
309
|
+
lastItem !== null &&
|
|
310
|
+
lastItem.comment === "") {
|
|
311
|
+
// clean up spacing as best we can for the diffed d.ts
|
|
312
|
+
lastItem.comment = node.getText().replace(/ \*/g, "*");
|
|
313
|
+
if (lastItem.comment.indexOf("@eventproperty") >= 0) {
|
|
314
|
+
// events are indistinguishable from properties aside from this tag
|
|
315
|
+
lastItem.type = FieldType.Event;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
node.getChildren().forEach((element) => {
|
|
320
|
+
parseDTSInternal(element, allClasses);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function parseDTSTopLevelItem(node, allClasses, type) {
|
|
324
|
+
topClass = new ClassStruct("export " + type.toLowerCase() + " " + node.name.text, "", type);
|
|
325
|
+
allClasses.addClass(topClass);
|
|
326
|
+
lastItem = topClass;
|
|
327
|
+
}
|
|
328
|
+
function parseDTSFieldItem(node, type) {
|
|
329
|
+
const newField = new FieldStruct(node.getText(), "", type, node.name.getText());
|
|
330
|
+
topClass.fields.push(newField);
|
|
331
|
+
lastItem = newField;
|
|
332
|
+
}
|
|
306
333
|
//# sourceMappingURL=dts-utilities.js.map
|