typedoc 0.23.24 → 0.23.25
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 +1 -1
- package/dist/index.js +5 -2
- package/dist/lib/application.d.ts +0 -2
- package/dist/lib/application.js +38 -14
- package/dist/lib/converter/comments/discovery.d.ts +1 -1
- package/dist/lib/converter/comments/discovery.js +77 -74
- package/dist/lib/converter/comments/index.d.ts +1 -1
- package/dist/lib/converter/comments/index.js +18 -15
- package/dist/lib/converter/comments/linkResolver.js +6 -3
- package/dist/lib/converter/context.d.ts +2 -2
- package/dist/lib/converter/context.js +6 -3
- package/dist/lib/converter/convert-expression.d.ts +1 -1
- package/dist/lib/converter/convert-expression.js +16 -13
- package/dist/lib/converter/converter.d.ts +1 -1
- package/dist/lib/converter/converter.js +12 -9
- package/dist/lib/converter/factories/index-signature.d.ts +1 -1
- package/dist/lib/converter/factories/index-signature.js +8 -5
- package/dist/lib/converter/factories/signature.d.ts +1 -1
- package/dist/lib/converter/factories/signature.js +32 -29
- package/dist/lib/converter/jsdoc.d.ts +1 -1
- package/dist/lib/converter/jsdoc.js +18 -15
- package/dist/lib/converter/plugins/CommentPlugin.d.ts +2 -0
- package/dist/lib/converter/plugins/CommentPlugin.js +19 -4
- package/dist/lib/converter/plugins/ImplementsPlugin.js +10 -7
- package/dist/lib/converter/plugins/PackagePlugin.js +25 -2
- package/dist/lib/converter/plugins/SourcePlugin.js +7 -4
- package/dist/lib/converter/symbols.d.ts +1 -1
- package/dist/lib/converter/symbols.js +129 -126
- package/dist/lib/converter/types.d.ts +1 -1
- package/dist/lib/converter/types.js +101 -98
- package/dist/lib/converter/utils/base-path.js +24 -1
- package/dist/lib/converter/utils/nodes.d.ts +1 -1
- package/dist/lib/converter/utils/nodes.js +5 -2
- package/dist/lib/converter/utils/symbols.d.ts +1 -1
- package/dist/lib/converter/utils/symbols.js +5 -2
- package/dist/lib/output/components.js +24 -1
- package/dist/lib/output/events.js +24 -1
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +24 -1
- package/dist/lib/output/renderer.js +25 -2
- package/dist/lib/output/themes/MarkedPlugin.js +26 -3
- package/dist/lib/serialization/index.js +24 -1
- package/dist/lib/utils/entry-point.d.ts +1 -1
- package/dist/lib/utils/entry-point.js +35 -9
- package/dist/lib/utils/fs.js +33 -3
- package/dist/lib/utils/general.js +24 -1
- package/dist/lib/utils/highlighter.js +24 -1
- package/dist/lib/utils/index.js +14 -2
- package/dist/lib/utils/loggers.d.ts +1 -1
- package/dist/lib/utils/loggers.js +9 -6
- package/dist/lib/utils/options/declaration.d.ts +1 -0
- package/dist/lib/utils/options/readers/tsconfig.js +8 -5
- package/dist/lib/utils/options/readers/typedoc.d.ts +1 -1
- package/dist/lib/utils/options/readers/typedoc.js +39 -5
- package/dist/lib/utils/options/sources/typedoc.js +79 -11
- package/dist/lib/utils/package-manifest.d.ts +1 -1
- package/dist/lib/utils/paths.d.ts +2 -2
- package/dist/lib/utils/plugins.js +25 -2
- package/dist/lib/validation/exports.js +5 -2
- package/package.json +12 -12
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.convertType = exports.loadConverters = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
7
|
+
const assert_1 = __importDefault(require("assert"));
|
|
8
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
6
9
|
const models_1 = require("../models");
|
|
7
10
|
const array_1 = require("../utils/array");
|
|
8
11
|
const converter_events_1 = require("./converter-events");
|
|
@@ -51,7 +54,7 @@ function loadConverters() {
|
|
|
51
54
|
// Might happen if running on an older TS version.
|
|
52
55
|
continue;
|
|
53
56
|
}
|
|
54
|
-
|
|
57
|
+
(0, assert_1.default)(!converters.has(key));
|
|
55
58
|
converters.set(key, actor);
|
|
56
59
|
}
|
|
57
60
|
}
|
|
@@ -79,12 +82,12 @@ function convertType(context, typeOrNode) {
|
|
|
79
82
|
return requestBugReport(context, typeOrNode);
|
|
80
83
|
}
|
|
81
84
|
// IgnoreErrors is important, without it, we can't assert that we will get a node.
|
|
82
|
-
const node = context.checker.typeToTypeNode(typeOrNode, void 0,
|
|
83
|
-
|
|
85
|
+
const node = context.checker.typeToTypeNode(typeOrNode, void 0, typescript_1.default.NodeBuilderFlags.IgnoreErrors);
|
|
86
|
+
(0, assert_1.default)(node); // According to the TS source of typeToString, this is a bug if it does not hold.
|
|
84
87
|
const symbol = typeOrNode.getSymbol();
|
|
85
88
|
if (symbol) {
|
|
86
|
-
if (node.kind !==
|
|
87
|
-
node.kind !==
|
|
89
|
+
if (node.kind !== typescript_1.default.SyntaxKind.TypeReference &&
|
|
90
|
+
node.kind !== typescript_1.default.SyntaxKind.ArrayType &&
|
|
88
91
|
seenTypeSymbols.has(symbol)) {
|
|
89
92
|
const typeString = context.checker.typeToString(typeOrNode);
|
|
90
93
|
context.logger.verbose(`Refusing to recurse when converting type: ${typeString}`);
|
|
@@ -108,7 +111,7 @@ function convertType(context, typeOrNode) {
|
|
|
108
111
|
}
|
|
109
112
|
exports.convertType = convertType;
|
|
110
113
|
const arrayConverter = {
|
|
111
|
-
kind: [
|
|
114
|
+
kind: [typescript_1.default.SyntaxKind.ArrayType],
|
|
112
115
|
convert(context, node) {
|
|
113
116
|
return new models_1.ArrayType(convertType(context, node.elementType));
|
|
114
117
|
},
|
|
@@ -116,12 +119,12 @@ const arrayConverter = {
|
|
|
116
119
|
const params = context.checker.getTypeArguments(type);
|
|
117
120
|
// This is *almost* always true... except for when this type is in the constraint of a type parameter see GH#1408
|
|
118
121
|
// assert(params.length === 1);
|
|
119
|
-
|
|
122
|
+
(0, assert_1.default)(params.length > 0);
|
|
120
123
|
return new models_1.ArrayType(convertType(context, params[0]));
|
|
121
124
|
},
|
|
122
125
|
};
|
|
123
126
|
const conditionalConverter = {
|
|
124
|
-
kind: [
|
|
127
|
+
kind: [typescript_1.default.SyntaxKind.ConditionalType],
|
|
125
128
|
convert(context, node) {
|
|
126
129
|
return new models_1.ConditionalType(convertType(context, node.checkType), convertType(context, node.extendsType), convertType(context, node.trueType), convertType(context, node.falseType));
|
|
127
130
|
},
|
|
@@ -130,7 +133,7 @@ const conditionalConverter = {
|
|
|
130
133
|
},
|
|
131
134
|
};
|
|
132
135
|
const constructorConverter = {
|
|
133
|
-
kind: [
|
|
136
|
+
kind: [typescript_1.default.SyntaxKind.ConstructorType],
|
|
134
137
|
convert(context, node) {
|
|
135
138
|
const symbol = context.getSymbolAtLocation(node) ?? node.symbol;
|
|
136
139
|
const type = context.getTypeAtLocation(node);
|
|
@@ -146,7 +149,7 @@ const constructorConverter = {
|
|
|
146
149
|
// This is unfortunate... but seems the obvious place to put this with the current
|
|
147
150
|
// architecture. Ideally, this would be a property on a "ConstructorType"... but that
|
|
148
151
|
// needs to wait until TypeDoc 0.22 when making other breaking changes.
|
|
149
|
-
if (node.modifiers?.some((m) => m.kind ===
|
|
152
|
+
if (node.modifiers?.some((m) => m.kind === typescript_1.default.SyntaxKind.AbstractKeyword)) {
|
|
150
153
|
signature.setFlag(models_1.ReflectionFlag.Abstract);
|
|
151
154
|
}
|
|
152
155
|
context.registerReflection(signature, void 0);
|
|
@@ -169,7 +172,7 @@ const constructorConverter = {
|
|
|
169
172
|
},
|
|
170
173
|
};
|
|
171
174
|
const exprWithTypeArgsConverter = {
|
|
172
|
-
kind: [
|
|
175
|
+
kind: [typescript_1.default.SyntaxKind.ExpressionWithTypeArguments],
|
|
173
176
|
convert(context, node) {
|
|
174
177
|
const targetSymbol = context.getSymbolAtLocation(node.expression);
|
|
175
178
|
// Mixins... we might not have a symbol here.
|
|
@@ -184,7 +187,7 @@ const exprWithTypeArgsConverter = {
|
|
|
184
187
|
convertType: requestBugReport,
|
|
185
188
|
};
|
|
186
189
|
const functionTypeConverter = {
|
|
187
|
-
kind: [
|
|
190
|
+
kind: [typescript_1.default.SyntaxKind.FunctionType],
|
|
188
191
|
convert(context, node) {
|
|
189
192
|
const symbol = context.getSymbolAtLocation(node) ?? node.symbol;
|
|
190
193
|
const type = context.getTypeAtLocation(node);
|
|
@@ -216,21 +219,21 @@ const functionTypeConverter = {
|
|
|
216
219
|
},
|
|
217
220
|
};
|
|
218
221
|
const importType = {
|
|
219
|
-
kind: [
|
|
222
|
+
kind: [typescript_1.default.SyntaxKind.ImportType],
|
|
220
223
|
convert(context, node) {
|
|
221
224
|
const name = node.qualifier?.getText() ?? "__module";
|
|
222
225
|
const symbol = context.checker.getSymbolAtLocation(node);
|
|
223
|
-
|
|
226
|
+
(0, assert_1.default)(symbol, "Missing symbol when converting import type node");
|
|
224
227
|
return models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
|
|
225
228
|
},
|
|
226
229
|
convertType(context, type) {
|
|
227
230
|
const symbol = type.getSymbol();
|
|
228
|
-
|
|
231
|
+
(0, assert_1.default)(symbol, "Missing symbol when converting import type"); // Should be a compiler error
|
|
229
232
|
return models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context, "__module");
|
|
230
233
|
},
|
|
231
234
|
};
|
|
232
235
|
const indexedAccessConverter = {
|
|
233
|
-
kind: [
|
|
236
|
+
kind: [typescript_1.default.SyntaxKind.IndexedAccessType],
|
|
234
237
|
convert(context, node) {
|
|
235
238
|
return new models_1.IndexedAccessType(convertType(context, node.objectType), convertType(context, node.indexType));
|
|
236
239
|
},
|
|
@@ -239,7 +242,7 @@ const indexedAccessConverter = {
|
|
|
239
242
|
},
|
|
240
243
|
};
|
|
241
244
|
const inferredConverter = {
|
|
242
|
-
kind: [
|
|
245
|
+
kind: [typescript_1.default.SyntaxKind.InferType],
|
|
243
246
|
convert(context, node) {
|
|
244
247
|
return new models_1.InferredType(node.typeParameter.name.text, maybeConvertType(context, node.typeParameter.constraint));
|
|
245
248
|
},
|
|
@@ -248,7 +251,7 @@ const inferredConverter = {
|
|
|
248
251
|
},
|
|
249
252
|
};
|
|
250
253
|
const intersectionConverter = {
|
|
251
|
-
kind: [
|
|
254
|
+
kind: [typescript_1.default.SyntaxKind.IntersectionType],
|
|
252
255
|
convert(context, node) {
|
|
253
256
|
return new models_1.IntersectionType(node.types.map((type) => convertType(context, type)));
|
|
254
257
|
},
|
|
@@ -257,7 +260,7 @@ const intersectionConverter = {
|
|
|
257
260
|
},
|
|
258
261
|
};
|
|
259
262
|
const jsDocVariadicTypeConverter = {
|
|
260
|
-
kind: [
|
|
263
|
+
kind: [typescript_1.default.SyntaxKind.JSDocVariadicType],
|
|
261
264
|
convert(context, node) {
|
|
262
265
|
return new models_1.ArrayType(convertType(context, node.type));
|
|
263
266
|
},
|
|
@@ -265,32 +268,32 @@ const jsDocVariadicTypeConverter = {
|
|
|
265
268
|
convertType: requestBugReport,
|
|
266
269
|
};
|
|
267
270
|
const keywordNames = {
|
|
268
|
-
[
|
|
269
|
-
[
|
|
270
|
-
[
|
|
271
|
-
[
|
|
272
|
-
[
|
|
273
|
-
[
|
|
274
|
-
[
|
|
275
|
-
[
|
|
276
|
-
[
|
|
277
|
-
[
|
|
278
|
-
[
|
|
279
|
-
[
|
|
271
|
+
[typescript_1.default.SyntaxKind.AnyKeyword]: "any",
|
|
272
|
+
[typescript_1.default.SyntaxKind.BigIntKeyword]: "bigint",
|
|
273
|
+
[typescript_1.default.SyntaxKind.BooleanKeyword]: "boolean",
|
|
274
|
+
[typescript_1.default.SyntaxKind.NeverKeyword]: "never",
|
|
275
|
+
[typescript_1.default.SyntaxKind.NumberKeyword]: "number",
|
|
276
|
+
[typescript_1.default.SyntaxKind.ObjectKeyword]: "object",
|
|
277
|
+
[typescript_1.default.SyntaxKind.StringKeyword]: "string",
|
|
278
|
+
[typescript_1.default.SyntaxKind.SymbolKeyword]: "symbol",
|
|
279
|
+
[typescript_1.default.SyntaxKind.UndefinedKeyword]: "undefined",
|
|
280
|
+
[typescript_1.default.SyntaxKind.UnknownKeyword]: "unknown",
|
|
281
|
+
[typescript_1.default.SyntaxKind.VoidKeyword]: "void",
|
|
282
|
+
[typescript_1.default.SyntaxKind.IntrinsicKeyword]: "intrinsic",
|
|
280
283
|
};
|
|
281
284
|
const keywordConverter = {
|
|
282
285
|
kind: [
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
286
|
+
typescript_1.default.SyntaxKind.AnyKeyword,
|
|
287
|
+
typescript_1.default.SyntaxKind.BigIntKeyword,
|
|
288
|
+
typescript_1.default.SyntaxKind.BooleanKeyword,
|
|
289
|
+
typescript_1.default.SyntaxKind.NeverKeyword,
|
|
290
|
+
typescript_1.default.SyntaxKind.NumberKeyword,
|
|
291
|
+
typescript_1.default.SyntaxKind.ObjectKeyword,
|
|
292
|
+
typescript_1.default.SyntaxKind.StringKeyword,
|
|
293
|
+
typescript_1.default.SyntaxKind.SymbolKeyword,
|
|
294
|
+
typescript_1.default.SyntaxKind.UndefinedKeyword,
|
|
295
|
+
typescript_1.default.SyntaxKind.UnknownKeyword,
|
|
296
|
+
typescript_1.default.SyntaxKind.VoidKeyword,
|
|
294
297
|
],
|
|
295
298
|
convert(_context, node) {
|
|
296
299
|
return new models_1.IntrinsicType(keywordNames[node.kind]);
|
|
@@ -300,7 +303,7 @@ const keywordConverter = {
|
|
|
300
303
|
},
|
|
301
304
|
};
|
|
302
305
|
const optionalConverter = {
|
|
303
|
-
kind: [
|
|
306
|
+
kind: [typescript_1.default.SyntaxKind.OptionalType],
|
|
304
307
|
convert(context, node) {
|
|
305
308
|
return new models_1.OptionalType((0, reflections_1.removeUndefined)(convertType(context, node.type)));
|
|
306
309
|
},
|
|
@@ -308,7 +311,7 @@ const optionalConverter = {
|
|
|
308
311
|
convertType: requestBugReport,
|
|
309
312
|
};
|
|
310
313
|
const parensConverter = {
|
|
311
|
-
kind: [
|
|
314
|
+
kind: [typescript_1.default.SyntaxKind.ParenthesizedType],
|
|
312
315
|
convert(context, node) {
|
|
313
316
|
return convertType(context, node.type);
|
|
314
317
|
},
|
|
@@ -316,9 +319,9 @@ const parensConverter = {
|
|
|
316
319
|
convertType: requestBugReport,
|
|
317
320
|
};
|
|
318
321
|
const predicateConverter = {
|
|
319
|
-
kind: [
|
|
322
|
+
kind: [typescript_1.default.SyntaxKind.TypePredicate],
|
|
320
323
|
convert(context, node) {
|
|
321
|
-
const name =
|
|
324
|
+
const name = typescript_1.default.isThisTypeNode(node.parameterName)
|
|
322
325
|
? "this"
|
|
323
326
|
: node.parameterName.getText();
|
|
324
327
|
const asserts = !!node.assertsModifier;
|
|
@@ -331,7 +334,7 @@ const predicateConverter = {
|
|
|
331
334
|
// This is a horrible thing... we're going to want to split this into converters
|
|
332
335
|
// for different types at some point.
|
|
333
336
|
const typeLiteralConverter = {
|
|
334
|
-
kind: [
|
|
337
|
+
kind: [typescript_1.default.SyntaxKind.TypeLiteral],
|
|
335
338
|
convert(context, node) {
|
|
336
339
|
const symbol = context.getSymbolAtLocation(node) ?? node.symbol;
|
|
337
340
|
const type = context.getTypeAtLocation(node);
|
|
@@ -376,7 +379,7 @@ const typeLiteralConverter = {
|
|
|
376
379
|
},
|
|
377
380
|
};
|
|
378
381
|
const queryConverter = {
|
|
379
|
-
kind: [
|
|
382
|
+
kind: [typescript_1.default.SyntaxKind.TypeQuery],
|
|
380
383
|
convert(context, node) {
|
|
381
384
|
const querySymbol = context.getSymbolAtLocation(node.exprName);
|
|
382
385
|
if (!querySymbol) {
|
|
@@ -388,14 +391,14 @@ const queryConverter = {
|
|
|
388
391
|
},
|
|
389
392
|
convertType(context, type) {
|
|
390
393
|
const symbol = type.getSymbol();
|
|
391
|
-
|
|
394
|
+
(0, assert_1.default)(symbol, `Query type failed to get a symbol for: ${context.checker.typeToString(type)}. This is a bug.`);
|
|
392
395
|
return new models_1.QueryType(models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context));
|
|
393
396
|
},
|
|
394
397
|
};
|
|
395
398
|
const referenceConverter = {
|
|
396
|
-
kind: [
|
|
399
|
+
kind: [typescript_1.default.SyntaxKind.TypeReference],
|
|
397
400
|
convert(context, node) {
|
|
398
|
-
const isArray = context.checker.typeToTypeNode(context.checker.getTypeAtLocation(node.typeName), void 0,
|
|
401
|
+
const isArray = context.checker.typeToTypeNode(context.checker.getTypeAtLocation(node.typeName), void 0, typescript_1.default.NodeBuilderFlags.IgnoreErrors)?.kind === typescript_1.default.SyntaxKind.ArrayType;
|
|
399
402
|
if (isArray) {
|
|
400
403
|
return new models_1.ArrayType(convertType(context, node.typeArguments?.[0]));
|
|
401
404
|
}
|
|
@@ -413,7 +416,7 @@ const referenceConverter = {
|
|
|
413
416
|
return models_1.ReferenceType.createBrokenReference(context.checker.typeToString(type), context.project);
|
|
414
417
|
}
|
|
415
418
|
const ref = models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context);
|
|
416
|
-
if (type.flags &
|
|
419
|
+
if (type.flags & typescript_1.default.TypeFlags.StringMapping) {
|
|
417
420
|
ref.typeArguments = [
|
|
418
421
|
convertType(context, type.type),
|
|
419
422
|
];
|
|
@@ -427,7 +430,7 @@ const referenceConverter = {
|
|
|
427
430
|
},
|
|
428
431
|
};
|
|
429
432
|
const restConverter = {
|
|
430
|
-
kind: [
|
|
433
|
+
kind: [typescript_1.default.SyntaxKind.RestType],
|
|
431
434
|
convert(context, node) {
|
|
432
435
|
return new models_1.RestType(convertType(context, node.type));
|
|
433
436
|
},
|
|
@@ -435,7 +438,7 @@ const restConverter = {
|
|
|
435
438
|
convertType: requestBugReport,
|
|
436
439
|
};
|
|
437
440
|
const namedTupleMemberConverter = {
|
|
438
|
-
kind: [
|
|
441
|
+
kind: [typescript_1.default.SyntaxKind.NamedTupleMember],
|
|
439
442
|
convert(context, node) {
|
|
440
443
|
const innerType = convertType(context, node.type);
|
|
441
444
|
return new models_1.NamedTupleMember(node.name.getText(), !!node.questionToken, innerType);
|
|
@@ -450,7 +453,7 @@ const namedTupleMemberConverter = {
|
|
|
450
453
|
// ^ questionToken
|
|
451
454
|
// ^^^^^^ type
|
|
452
455
|
const mappedConverter = {
|
|
453
|
-
kind: [
|
|
456
|
+
kind: [typescript_1.default.SyntaxKind.MappedType],
|
|
454
457
|
convert(context, node) {
|
|
455
458
|
const optionalModifier = kindToModifier(node.questionToken?.kind);
|
|
456
459
|
const templateType = convertType(context, node.type);
|
|
@@ -468,47 +471,47 @@ const mappedConverter = {
|
|
|
468
471
|
},
|
|
469
472
|
};
|
|
470
473
|
const literalTypeConverter = {
|
|
471
|
-
kind: [
|
|
474
|
+
kind: [typescript_1.default.SyntaxKind.LiteralType],
|
|
472
475
|
convert(context, node) {
|
|
473
476
|
switch (node.literal.kind) {
|
|
474
|
-
case
|
|
475
|
-
case
|
|
476
|
-
return new models_1.LiteralType(node.literal.kind ===
|
|
477
|
-
case
|
|
477
|
+
case typescript_1.default.SyntaxKind.TrueKeyword:
|
|
478
|
+
case typescript_1.default.SyntaxKind.FalseKeyword:
|
|
479
|
+
return new models_1.LiteralType(node.literal.kind === typescript_1.default.SyntaxKind.TrueKeyword);
|
|
480
|
+
case typescript_1.default.SyntaxKind.StringLiteral:
|
|
478
481
|
return new models_1.LiteralType(node.literal.text);
|
|
479
|
-
case
|
|
482
|
+
case typescript_1.default.SyntaxKind.NumericLiteral:
|
|
480
483
|
return new models_1.LiteralType(Number(node.literal.text));
|
|
481
|
-
case
|
|
484
|
+
case typescript_1.default.SyntaxKind.NullKeyword:
|
|
482
485
|
return new models_1.LiteralType(null);
|
|
483
|
-
case
|
|
486
|
+
case typescript_1.default.SyntaxKind.PrefixUnaryExpression: {
|
|
484
487
|
const operand = node.literal
|
|
485
488
|
.operand;
|
|
486
489
|
switch (operand.kind) {
|
|
487
|
-
case
|
|
490
|
+
case typescript_1.default.SyntaxKind.NumericLiteral:
|
|
488
491
|
return new models_1.LiteralType(Number(node.literal.getText()));
|
|
489
|
-
case
|
|
492
|
+
case typescript_1.default.SyntaxKind.BigIntLiteral:
|
|
490
493
|
return new models_1.LiteralType(BigInt(node.literal.getText().replace("n", "")));
|
|
491
494
|
default:
|
|
492
495
|
return requestBugReport(context, node.literal);
|
|
493
496
|
}
|
|
494
497
|
}
|
|
495
|
-
case
|
|
498
|
+
case typescript_1.default.SyntaxKind.BigIntLiteral:
|
|
496
499
|
return new models_1.LiteralType(BigInt(node.literal.getText().replace("n", "")));
|
|
497
|
-
case
|
|
500
|
+
case typescript_1.default.SyntaxKind.NoSubstitutionTemplateLiteral:
|
|
498
501
|
return new models_1.LiteralType(node.literal.text);
|
|
499
502
|
}
|
|
500
503
|
return requestBugReport(context, node.literal);
|
|
501
504
|
},
|
|
502
505
|
convertType(_context, type, node) {
|
|
503
506
|
switch (node.literal.kind) {
|
|
504
|
-
case
|
|
507
|
+
case typescript_1.default.SyntaxKind.StringLiteral:
|
|
505
508
|
return new models_1.LiteralType(node.literal.text);
|
|
506
|
-
case
|
|
509
|
+
case typescript_1.default.SyntaxKind.NumericLiteral:
|
|
507
510
|
return new models_1.LiteralType(+node.literal.text);
|
|
508
|
-
case
|
|
509
|
-
case
|
|
510
|
-
return new models_1.LiteralType(node.literal.kind ===
|
|
511
|
-
case
|
|
511
|
+
case typescript_1.default.SyntaxKind.TrueKeyword:
|
|
512
|
+
case typescript_1.default.SyntaxKind.FalseKeyword:
|
|
513
|
+
return new models_1.LiteralType(node.literal.kind === typescript_1.default.SyntaxKind.TrueKeyword);
|
|
514
|
+
case typescript_1.default.SyntaxKind.NullKeyword:
|
|
512
515
|
return new models_1.LiteralType(null);
|
|
513
516
|
}
|
|
514
517
|
if (typeof type.value === "object") {
|
|
@@ -518,14 +521,14 @@ const literalTypeConverter = {
|
|
|
518
521
|
},
|
|
519
522
|
};
|
|
520
523
|
const templateLiteralConverter = {
|
|
521
|
-
kind: [
|
|
524
|
+
kind: [typescript_1.default.SyntaxKind.TemplateLiteralType],
|
|
522
525
|
convert(context, node) {
|
|
523
526
|
return new models_1.TemplateLiteralType(node.head.text, node.templateSpans.map((span) => {
|
|
524
527
|
return [convertType(context, span.type), span.literal.text];
|
|
525
528
|
}));
|
|
526
529
|
},
|
|
527
530
|
convertType(context, type) {
|
|
528
|
-
|
|
531
|
+
(0, assert_1.default)(type.texts.length === type.types.length + 1);
|
|
529
532
|
const parts = [];
|
|
530
533
|
for (const [a, b] of (0, array_1.zip)(type.types, type.texts.slice(1))) {
|
|
531
534
|
parts.push([convertType(context, a), b]);
|
|
@@ -534,7 +537,7 @@ const templateLiteralConverter = {
|
|
|
534
537
|
},
|
|
535
538
|
};
|
|
536
539
|
const thisConverter = {
|
|
537
|
-
kind: [
|
|
540
|
+
kind: [typescript_1.default.SyntaxKind.ThisType],
|
|
538
541
|
convert() {
|
|
539
542
|
return new models_1.IntrinsicType("this");
|
|
540
543
|
},
|
|
@@ -543,7 +546,7 @@ const thisConverter = {
|
|
|
543
546
|
},
|
|
544
547
|
};
|
|
545
548
|
const tupleConverter = {
|
|
546
|
-
kind: [
|
|
549
|
+
kind: [typescript_1.default.SyntaxKind.TupleType],
|
|
547
550
|
convert(context, node) {
|
|
548
551
|
const elements = node.elements.map((node) => convertType(context, node));
|
|
549
552
|
return new models_1.TupleType(elements);
|
|
@@ -556,14 +559,14 @@ const tupleConverter = {
|
|
|
556
559
|
elements = elements?.map((el, i) => new models_1.NamedTupleMember(namedDeclarations[i].name.getText(), !!namedDeclarations[i].questionToken, (0, reflections_1.removeUndefined)(el)));
|
|
557
560
|
}
|
|
558
561
|
elements = elements?.map((el, i) => {
|
|
559
|
-
if (type.target.elementFlags[i] &
|
|
562
|
+
if (type.target.elementFlags[i] & typescript_1.default.ElementFlags.Variable) {
|
|
560
563
|
// In the node case, we don't need to add the wrapping Array type... but we do here.
|
|
561
564
|
if (el instanceof models_1.NamedTupleMember) {
|
|
562
565
|
return new models_1.RestType(new models_1.NamedTupleMember(el.name, el.isOptional, new models_1.ArrayType(el.element)));
|
|
563
566
|
}
|
|
564
567
|
return new models_1.RestType(new models_1.ArrayType(el));
|
|
565
568
|
}
|
|
566
|
-
if (type.target.elementFlags[i] &
|
|
569
|
+
if (type.target.elementFlags[i] & typescript_1.default.ElementFlags.Optional &&
|
|
567
570
|
!(el instanceof models_1.NamedTupleMember)) {
|
|
568
571
|
return new models_1.OptionalType((0, reflections_1.removeUndefined)(el));
|
|
569
572
|
}
|
|
@@ -573,31 +576,31 @@ const tupleConverter = {
|
|
|
573
576
|
},
|
|
574
577
|
};
|
|
575
578
|
const supportedOperatorNames = {
|
|
576
|
-
[
|
|
577
|
-
[
|
|
578
|
-
[
|
|
579
|
+
[typescript_1.default.SyntaxKind.KeyOfKeyword]: "keyof",
|
|
580
|
+
[typescript_1.default.SyntaxKind.UniqueKeyword]: "unique",
|
|
581
|
+
[typescript_1.default.SyntaxKind.ReadonlyKeyword]: "readonly",
|
|
579
582
|
};
|
|
580
583
|
const typeOperatorConverter = {
|
|
581
|
-
kind: [
|
|
584
|
+
kind: [typescript_1.default.SyntaxKind.TypeOperator],
|
|
582
585
|
convert(context, node) {
|
|
583
586
|
return new models_1.TypeOperatorType(convertType(context, node.type), supportedOperatorNames[node.operator]);
|
|
584
587
|
},
|
|
585
588
|
convertType(context, type, node) {
|
|
586
589
|
// readonly is only valid on array and tuple literal types.
|
|
587
|
-
if (node.operator ===
|
|
590
|
+
if (node.operator === typescript_1.default.SyntaxKind.ReadonlyKeyword) {
|
|
588
591
|
const resolved = resolveReference(type);
|
|
589
|
-
|
|
592
|
+
(0, assert_1.default)((0, nodes_1.isObjectType)(resolved));
|
|
590
593
|
const args = context.checker
|
|
591
594
|
.getTypeArguments(type)
|
|
592
595
|
.map((type) => convertType(context, type));
|
|
593
|
-
const inner = resolved.objectFlags &
|
|
596
|
+
const inner = resolved.objectFlags & typescript_1.default.ObjectFlags.Tuple
|
|
594
597
|
? new models_1.TupleType(args)
|
|
595
598
|
: new models_1.ArrayType(args[0]);
|
|
596
599
|
return new models_1.TypeOperatorType(inner, "readonly");
|
|
597
600
|
}
|
|
598
601
|
// keyof will only show up with generic functions, otherwise it gets eagerly
|
|
599
602
|
// resolved to a union of strings.
|
|
600
|
-
if (node.operator ===
|
|
603
|
+
if (node.operator === typescript_1.default.SyntaxKind.KeyOfKeyword) {
|
|
601
604
|
// TS 4.2 added this to enable better tracking of type aliases.
|
|
602
605
|
if (type.isUnion() && type.origin) {
|
|
603
606
|
return convertType(context, type.origin);
|
|
@@ -612,7 +615,7 @@ const typeOperatorConverter = {
|
|
|
612
615
|
},
|
|
613
616
|
};
|
|
614
617
|
const unionConverter = {
|
|
615
|
-
kind: [
|
|
618
|
+
kind: [typescript_1.default.SyntaxKind.UnionType],
|
|
616
619
|
convert(context, node) {
|
|
617
620
|
return new models_1.UnionType(node.types.map((type) => convertType(context, type)));
|
|
618
621
|
},
|
|
@@ -625,7 +628,7 @@ const unionConverter = {
|
|
|
625
628
|
},
|
|
626
629
|
};
|
|
627
630
|
const jsDocNullableTypeConverter = {
|
|
628
|
-
kind: [
|
|
631
|
+
kind: [typescript_1.default.SyntaxKind.JSDocNullableType],
|
|
629
632
|
convert(context, node) {
|
|
630
633
|
return new models_1.UnionType([
|
|
631
634
|
convertType(context, node.type),
|
|
@@ -636,7 +639,7 @@ const jsDocNullableTypeConverter = {
|
|
|
636
639
|
convertType: requestBugReport,
|
|
637
640
|
};
|
|
638
641
|
const jsDocNonNullableTypeConverter = {
|
|
639
|
-
kind: [
|
|
642
|
+
kind: [typescript_1.default.SyntaxKind.JSDocNonNullableType],
|
|
640
643
|
convert(context, node) {
|
|
641
644
|
return convertType(context, node.type);
|
|
642
645
|
},
|
|
@@ -645,7 +648,7 @@ const jsDocNonNullableTypeConverter = {
|
|
|
645
648
|
};
|
|
646
649
|
function requestBugReport(context, nodeOrType) {
|
|
647
650
|
if ("kind" in nodeOrType) {
|
|
648
|
-
const kindName =
|
|
651
|
+
const kindName = typescript_1.default.SyntaxKind[nodeOrType.kind];
|
|
649
652
|
context.logger.warn(`Failed to convert type node with kind: ${kindName} and text ${nodeOrType.getText()}. Please report a bug.`, nodeOrType);
|
|
650
653
|
return new models_1.UnknownType(nodeOrType.getText());
|
|
651
654
|
}
|
|
@@ -656,18 +659,18 @@ function requestBugReport(context, nodeOrType) {
|
|
|
656
659
|
}
|
|
657
660
|
}
|
|
658
661
|
function resolveReference(type) {
|
|
659
|
-
if ((0, nodes_1.isObjectType)(type) && type.objectFlags &
|
|
662
|
+
if ((0, nodes_1.isObjectType)(type) && type.objectFlags & typescript_1.default.ObjectFlags.Reference) {
|
|
660
663
|
return type.target;
|
|
661
664
|
}
|
|
662
665
|
return type;
|
|
663
666
|
}
|
|
664
667
|
function kindToModifier(kind) {
|
|
665
668
|
switch (kind) {
|
|
666
|
-
case
|
|
667
|
-
case
|
|
668
|
-
case
|
|
669
|
+
case typescript_1.default.SyntaxKind.ReadonlyKeyword:
|
|
670
|
+
case typescript_1.default.SyntaxKind.QuestionToken:
|
|
671
|
+
case typescript_1.default.SyntaxKind.PlusToken:
|
|
669
672
|
return "+";
|
|
670
|
-
case
|
|
673
|
+
case typescript_1.default.SyntaxKind.MinusToken:
|
|
671
674
|
return "-";
|
|
672
675
|
default:
|
|
673
676
|
return undefined;
|
|
@@ -1,7 +1,30 @@
|
|
|
1
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.BasePath = void 0;
|
|
4
|
-
const Path = require("path");
|
|
27
|
+
const Path = __importStar(require("path"));
|
|
5
28
|
/**
|
|
6
29
|
* Helper class that determines the common base path of a set of files.
|
|
7
30
|
*
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.isObjectType = exports.getHeritageTypes = exports.isNamedNode = void 0;
|
|
4
|
-
const
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
5
8
|
function isNamedNode(node) {
|
|
6
9
|
const name = node.name;
|
|
7
|
-
return !!name && (
|
|
10
|
+
return !!name && (typescript_1.default.isMemberName(name) || typescript_1.default.isComputedPropertyName(name));
|
|
8
11
|
}
|
|
9
12
|
exports.isNamedNode = isNamedNode;
|
|
10
13
|
function getHeritageTypes(declarations, kind) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ts from "typescript";
|
|
2
2
|
export declare function resolveAliasedSymbol(symbol: ts.Symbol, checker: ts.TypeChecker): ts.Symbol;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.resolveAliasedSymbol = void 0;
|
|
4
|
-
const
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
5
8
|
function resolveAliasedSymbol(symbol, checker) {
|
|
6
|
-
while (
|
|
9
|
+
while (typescript_1.default.SymbolFlags.Alias & symbol.flags) {
|
|
7
10
|
symbol = checker.getAliasedSymbol(symbol);
|
|
8
11
|
}
|
|
9
12
|
return symbol;
|
|
@@ -1,7 +1,30 @@
|
|
|
1
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.ContextAwareRendererComponent = exports.RendererComponent = exports.Component = void 0;
|
|
4
|
-
const Path = require("path");
|
|
27
|
+
const Path = __importStar(require("path"));
|
|
5
28
|
const component_1 = require("../utils/component");
|
|
6
29
|
Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return component_1.Component; } });
|
|
7
30
|
const index_1 = require("../models/reflections/index");
|
|
@@ -1,7 +1,30 @@
|
|
|
1
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.IndexEvent = exports.MarkdownEvent = exports.PageEvent = exports.RendererEvent = void 0;
|
|
4
|
-
const Path = require("path");
|
|
27
|
+
const Path = __importStar(require("path"));
|
|
5
28
|
const events_1 = require("../utils/events");
|
|
6
29
|
/**
|
|
7
30
|
* An event emitted by the {@link Renderer} class at the very beginning and
|