typedoc 0.22.13 → 0.22.16

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.
Files changed (54) hide show
  1. package/README.md +2 -2
  2. package/dist/lib/converter/context.d.ts +2 -0
  3. package/dist/lib/converter/context.js +6 -0
  4. package/dist/lib/converter/converter.js +6 -1
  5. package/dist/lib/converter/factories/signature.d.ts +1 -0
  6. package/dist/lib/converter/factories/signature.js +33 -14
  7. package/dist/lib/converter/plugins/CategoryPlugin.d.ts +10 -4
  8. package/dist/lib/converter/plugins/CategoryPlugin.js +24 -14
  9. package/dist/lib/converter/plugins/CommentPlugin.js +9 -4
  10. package/dist/lib/converter/plugins/GroupPlugin.js +3 -3
  11. package/dist/lib/converter/plugins/PackagePlugin.js +27 -3
  12. package/dist/lib/converter/symbols.js +29 -29
  13. package/dist/lib/converter/types.js +10 -4
  14. package/dist/lib/models/reflections/abstract.d.ts +7 -1
  15. package/dist/lib/models/reflections/abstract.js +20 -1
  16. package/dist/lib/models/reflections/container.d.ts +5 -0
  17. package/dist/lib/models/reflections/container.js +1 -1
  18. package/dist/lib/models/reflections/declaration.d.ts +2 -0
  19. package/dist/lib/models/reflections/declaration.js +2 -2
  20. package/dist/lib/models/reflections/index.d.ts +1 -1
  21. package/dist/lib/models/reflections/index.js +2 -1
  22. package/dist/lib/models/reflections/signature.js +2 -2
  23. package/dist/lib/models/reflections/type-parameter.d.ts +12 -4
  24. package/dist/lib/models/reflections/type-parameter.js +12 -5
  25. package/dist/lib/models/types.d.ts +92 -23
  26. package/dist/lib/models/types.js +327 -78
  27. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +18 -8
  28. package/dist/lib/output/plugins/LegendPlugin.js +1 -1
  29. package/dist/lib/output/plugins/MarkedLinksPlugin.js +1 -1
  30. package/dist/lib/output/renderer.d.ts +16 -0
  31. package/dist/lib/output/themes/default/layouts/default.js +8 -2
  32. package/dist/lib/output/themes/default/partials/header.js +3 -1
  33. package/dist/lib/output/themes/default/partials/member.declaration.js +2 -2
  34. package/dist/lib/output/themes/default/partials/member.signature.body.js +1 -1
  35. package/dist/lib/output/themes/default/partials/type.js +46 -44
  36. package/dist/lib/output/themes/default/partials/typeParameters.js +2 -1
  37. package/dist/lib/output/themes/default/templates/reflection.js +1 -1
  38. package/dist/lib/output/themes/lib.js +3 -1
  39. package/dist/lib/serialization/schema.d.ts +2 -2
  40. package/dist/lib/serialization/serializers/reflections/type-parameter.js +1 -0
  41. package/dist/lib/serialization/serializers/types/inferred.js +3 -0
  42. package/dist/lib/utils/entry-point.d.ts +1 -1
  43. package/dist/lib/utils/entry-point.js +6 -6
  44. package/dist/lib/utils/options/declaration.d.ts +14 -1
  45. package/dist/lib/utils/options/declaration.js +2 -0
  46. package/dist/lib/utils/options/options.js +5 -1
  47. package/dist/lib/utils/options/sources/typedoc.js +49 -5
  48. package/dist/lib/utils/package-manifest.js +1 -1
  49. package/dist/lib/utils/sort.d.ts +1 -1
  50. package/dist/lib/utils/sort.js +10 -9
  51. package/dist/lib/validation/documentation.js +55 -9
  52. package/package.json +16 -16
  53. package/static/main.js +2 -2
  54. package/static/style.css +3 -2
@@ -68,6 +68,8 @@ export declare class DeclarationReflection extends ContainerReflection {
68
68
  * The default value of this reflection.
69
69
  *
70
70
  * Applies to function parameters.
71
+ *
72
+ * Note: Using this for enum members is DEPRECATED and will be removed in 0.23.
71
73
  */
72
74
  defaultValue?: string;
73
75
  /**
@@ -45,7 +45,7 @@ class DeclarationReflection extends container_1.ContainerReflection {
45
45
  */
46
46
  traverse(callback) {
47
47
  var _a, _b;
48
- for (const parameter of (_a = this.typeParameters) !== null && _a !== void 0 ? _a : []) {
48
+ for (const parameter of ((_a = this.typeParameters) === null || _a === void 0 ? void 0 : _a.slice()) || []) {
49
49
  if (callback(parameter, abstract_1.TraverseProperty.TypeParameter) === false) {
50
50
  return;
51
51
  }
@@ -55,7 +55,7 @@ class DeclarationReflection extends container_1.ContainerReflection {
55
55
  return;
56
56
  }
57
57
  }
58
- for (const signature of (_b = this.signatures) !== null && _b !== void 0 ? _b : []) {
58
+ for (const signature of ((_b = this.signatures) === null || _b === void 0 ? void 0 : _b.slice()) || []) {
59
59
  if (callback(signature, abstract_1.TraverseProperty.Signatures) === false) {
60
60
  return;
61
61
  }
@@ -8,5 +8,5 @@ export { ParameterReflection } from "./parameter";
8
8
  export { ProjectReflection } from "./project";
9
9
  export { ReferenceReflection } from "./reference";
10
10
  export { SignatureReflection } from "./signature";
11
- export { TypeParameterReflection } from "./type-parameter";
11
+ export { TypeParameterReflection, VarianceModifier } from "./type-parameter";
12
12
  export { splitUnquotedString } from "./utils";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.splitUnquotedString = exports.TypeParameterReflection = exports.SignatureReflection = exports.ReferenceReflection = exports.ProjectReflection = exports.ParameterReflection = exports.ReflectionKind = exports.DeclarationReflection = exports.ContainerReflection = exports.TraverseProperty = exports.ReflectionFlags = exports.ReflectionFlag = exports.Reflection = void 0;
3
+ exports.splitUnquotedString = exports.VarianceModifier = exports.TypeParameterReflection = exports.SignatureReflection = exports.ReferenceReflection = exports.ProjectReflection = exports.ParameterReflection = exports.ReflectionKind = exports.DeclarationReflection = exports.ContainerReflection = exports.TraverseProperty = exports.ReflectionFlags = exports.ReflectionFlag = exports.Reflection = void 0;
4
4
  var abstract_1 = require("./abstract");
5
5
  Object.defineProperty(exports, "Reflection", { enumerable: true, get: function () { return abstract_1.Reflection; } });
6
6
  Object.defineProperty(exports, "ReflectionFlag", { enumerable: true, get: function () { return abstract_1.ReflectionFlag; } });
@@ -22,5 +22,6 @@ var signature_1 = require("./signature");
22
22
  Object.defineProperty(exports, "SignatureReflection", { enumerable: true, get: function () { return signature_1.SignatureReflection; } });
23
23
  var type_parameter_1 = require("./type-parameter");
24
24
  Object.defineProperty(exports, "TypeParameterReflection", { enumerable: true, get: function () { return type_parameter_1.TypeParameterReflection; } });
25
+ Object.defineProperty(exports, "VarianceModifier", { enumerable: true, get: function () { return type_parameter_1.VarianceModifier; } });
25
26
  var utils_1 = require("./utils");
26
27
  Object.defineProperty(exports, "splitUnquotedString", { enumerable: true, get: function () { return utils_1.splitUnquotedString; } });
@@ -25,12 +25,12 @@ class SignatureReflection extends abstract_1.Reflection {
25
25
  return;
26
26
  }
27
27
  }
28
- for (const parameter of (_a = this.typeParameters) !== null && _a !== void 0 ? _a : []) {
28
+ for (const parameter of ((_a = this.typeParameters) === null || _a === void 0 ? void 0 : _a.slice()) || []) {
29
29
  if (callback(parameter, abstract_1.TraverseProperty.TypeParameter) === false) {
30
30
  return;
31
31
  }
32
32
  }
33
- for (const parameter of (_b = this.parameters) !== null && _b !== void 0 ? _b : []) {
33
+ for (const parameter of ((_b = this.parameters) === null || _b === void 0 ? void 0 : _b.slice()) || []) {
34
34
  if (callback(parameter, abstract_1.TraverseProperty.Parameters) === false) {
35
35
  return;
36
36
  }
@@ -1,12 +1,20 @@
1
1
  import type { Type } from "../types";
2
2
  import { Reflection } from "./abstract";
3
3
  import type { DeclarationReflection } from "./declaration";
4
+ /**
5
+ * Modifier flags for type parameters, added in TS 4.7
6
+ * @enum
7
+ */
8
+ export declare const VarianceModifier: {
9
+ readonly in: "in";
10
+ readonly out: "out";
11
+ readonly inOut: "in out";
12
+ };
13
+ export declare type VarianceModifier = typeof VarianceModifier[keyof typeof VarianceModifier];
4
14
  export declare class TypeParameterReflection extends Reflection {
5
15
  parent?: DeclarationReflection;
6
16
  type?: Type;
7
17
  default?: Type;
8
- /**
9
- * Create a new TypeParameterReflection instance.
10
- */
11
- constructor(name: string, constraint?: Type, defaultType?: Type, parent?: Reflection);
18
+ varianceModifier?: VarianceModifier;
19
+ constructor(name: string, constraint: Type | undefined, defaultType: Type | undefined, parent: Reflection, varianceModifier: VarianceModifier | undefined);
12
20
  }
@@ -1,16 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeParameterReflection = void 0;
3
+ exports.TypeParameterReflection = exports.VarianceModifier = void 0;
4
4
  const abstract_1 = require("./abstract");
5
5
  const kind_1 = require("./kind");
6
+ /**
7
+ * Modifier flags for type parameters, added in TS 4.7
8
+ * @enum
9
+ */
10
+ exports.VarianceModifier = {
11
+ in: "in",
12
+ out: "out",
13
+ inOut: "in out",
14
+ };
6
15
  class TypeParameterReflection extends abstract_1.Reflection {
7
- /**
8
- * Create a new TypeParameterReflection instance.
9
- */
10
- constructor(name, constraint, defaultType, parent) {
16
+ constructor(name, constraint, defaultType, parent, varianceModifier) {
11
17
  super(name, kind_1.ReflectionKind.TypeParameter, parent);
12
18
  this.type = constraint;
13
19
  this.default = defaultType;
20
+ this.varianceModifier = varianceModifier;
14
21
  }
15
22
  }
16
23
  exports.TypeParameterReflection = TypeParameterReflection;
@@ -14,12 +14,19 @@ export declare abstract class Type {
14
14
  /**
15
15
  * Return a string representation of this type.
16
16
  */
17
- abstract toString(): string;
17
+ toString(): string;
18
18
  /**
19
19
  * Visit this type, returning the value returned by the visitor.
20
20
  */
21
21
  visit<T>(visitor: TypeVisitor<T>): T;
22
22
  visit<T>(visitor: Partial<TypeVisitor<T>>): T | undefined;
23
+ stringify(context: TypeContext): string;
24
+ abstract needsParenthesis(context: TypeContext): boolean;
25
+ /**
26
+ * Implementation method for `toString`. `needsParenthesis` will be used to determine if
27
+ * the returned string should be wrapped in parenthesis.
28
+ */
29
+ protected abstract getTypeString(): string;
23
30
  }
24
31
  export interface TypeKindMap {
25
32
  array: ArrayType;
@@ -49,6 +56,37 @@ export declare type TypeVisitor<T = void> = {
49
56
  export declare function makeRecursiveVisitor(visitor: Partial<TypeVisitor>): TypeVisitor;
50
57
  export declare type TypeKind = keyof TypeKindMap;
51
58
  export declare type SomeType = TypeKindMap[keyof TypeKindMap];
59
+ /**
60
+ * Enumeration that can be used when traversing types to track the location of recursion.
61
+ * Used by TypeDoc internally to track when to output parenthesis when rendering.
62
+ * @enum
63
+ */
64
+ export declare const TypeContext: {
65
+ readonly none: "none";
66
+ readonly templateLiteralElement: "templateLiteralElement";
67
+ readonly arrayElement: "arrayElement";
68
+ readonly indexedAccessElement: "indexedAccessElement";
69
+ readonly conditionalCheck: "conditionalCheck";
70
+ readonly conditionalExtends: "conditionalExtends";
71
+ readonly conditionalTrue: "conditionalTrue";
72
+ readonly conditionalFalse: "conditionalFalse";
73
+ readonly indexedIndex: "indexedIndex";
74
+ readonly indexedObject: "indexedObject";
75
+ readonly inferredConstraint: "inferredConstraint";
76
+ readonly intersectionElement: "intersectionElement";
77
+ readonly mappedName: "mappedName";
78
+ readonly mappedParameter: "mappedParameter";
79
+ readonly mappedTemplate: "mappedTemplate";
80
+ readonly optionalElement: "optionalElement";
81
+ readonly predicateTarget: "predicateTarget";
82
+ readonly queryTypeTarget: "queryTypeTarget";
83
+ readonly typeOperatorTarget: "typeOperatorTarget";
84
+ readonly referenceTypeArgument: "referenceTypeArgument";
85
+ readonly restElement: "restElement";
86
+ readonly tupleElement: "tupleElement";
87
+ readonly unionElement: "unionElement";
88
+ };
89
+ export declare type TypeContext = typeof TypeContext[keyof typeof TypeContext];
52
90
  /**
53
91
  * Represents an array type.
54
92
  *
@@ -63,7 +101,8 @@ export declare class ArrayType extends Type {
63
101
  */
64
102
  elementType: Type;
65
103
  constructor(elementType: Type);
66
- toString(): string;
104
+ protected getTypeString(): string;
105
+ needsParenthesis(): boolean;
67
106
  }
68
107
  /**
69
108
  * Represents a conditional type.
@@ -79,7 +118,8 @@ export declare class ConditionalType extends Type {
79
118
  falseType: Type;
80
119
  readonly type = "conditional";
81
120
  constructor(checkType: Type, extendsType: Type, trueType: Type, falseType: Type);
82
- toString(): string;
121
+ protected getTypeString(): string;
122
+ needsParenthesis(context: TypeContext): boolean;
83
123
  }
84
124
  /**
85
125
  * Represents an indexed access type.
@@ -89,7 +129,8 @@ export declare class IndexedAccessType extends Type {
89
129
  indexType: Type;
90
130
  readonly type = "indexedAccess";
91
131
  constructor(objectType: Type, indexType: Type);
92
- toString(): string;
132
+ protected getTypeString(): string;
133
+ needsParenthesis(): boolean;
93
134
  }
94
135
  /**
95
136
  * Represents an inferred type, U in the example below.
@@ -100,9 +141,11 @@ export declare class IndexedAccessType extends Type {
100
141
  */
101
142
  export declare class InferredType extends Type {
102
143
  name: string;
144
+ constraint?: SomeType | undefined;
103
145
  readonly type = "inferred";
104
- constructor(name: string);
105
- toString(): string;
146
+ constructor(name: string, constraint?: SomeType | undefined);
147
+ protected getTypeString(): string;
148
+ needsParenthesis(context: TypeContext): boolean;
106
149
  }
107
150
  /**
108
151
  * Represents an intersection type.
@@ -115,7 +158,8 @@ export declare class IntersectionType extends Type {
115
158
  types: Type[];
116
159
  readonly type = "intersection";
117
160
  constructor(types: Type[]);
118
- toString(): string;
161
+ protected getTypeString(): string;
162
+ needsParenthesis(context: TypeContext): boolean;
119
163
  }
120
164
  /**
121
165
  * Represents an intrinsic type like `string` or `boolean`.
@@ -128,7 +172,8 @@ export declare class IntrinsicType extends Type {
128
172
  name: string;
129
173
  readonly type = "intrinsic";
130
174
  constructor(name: string);
131
- toString(): string;
175
+ protected getTypeString(): string;
176
+ needsParenthesis(): boolean;
132
177
  }
133
178
  /**
134
179
  * Represents a literal type.
@@ -145,13 +190,14 @@ export declare class LiteralType extends Type {
145
190
  /**
146
191
  * Return a string representation of this type.
147
192
  */
148
- toString(): string;
193
+ protected getTypeString(): string;
194
+ needsParenthesis(): boolean;
149
195
  }
150
196
  /**
151
197
  * Represents a mapped type.
152
198
  *
153
199
  * ```ts
154
- * { -readonly [K in keyof U & string as `a${K}`]?: Foo }
200
+ * { -readonly [K in Parameter as Name]?: Template }
155
201
  * ```
156
202
  */
157
203
  export declare class MappedType extends Type {
@@ -163,7 +209,8 @@ export declare class MappedType extends Type {
163
209
  nameType?: Type | undefined;
164
210
  readonly type = "mapped";
165
211
  constructor(parameter: string, parameterType: Type, templateType: Type, readonlyModifier?: "-" | "+" | undefined, optionalModifier?: "-" | "+" | undefined, nameType?: Type | undefined);
166
- toString(): string;
212
+ protected getTypeString(): string;
213
+ needsParenthesis(): boolean;
167
214
  }
168
215
  /**
169
216
  * Represents an optional type
@@ -176,7 +223,8 @@ export declare class OptionalType extends Type {
176
223
  readonly type = "optional";
177
224
  elementType: Type;
178
225
  constructor(elementType: Type);
179
- toString(): string;
226
+ protected getTypeString(): string;
227
+ needsParenthesis(): boolean;
180
228
  }
181
229
  /**
182
230
  * Represents a type predicate.
@@ -210,7 +258,8 @@ export declare class PredicateType extends Type {
210
258
  /**
211
259
  * Return a string representation of this type.
212
260
  */
213
- toString(): string;
261
+ protected getTypeString(): string;
262
+ needsParenthesis(): boolean;
214
263
  }
215
264
  /**
216
265
  * Represents a type that is constructed by querying the type of a reflection.
@@ -223,7 +272,14 @@ export declare class QueryType extends Type {
223
272
  readonly queryType: ReferenceType;
224
273
  readonly type = "query";
225
274
  constructor(reference: ReferenceType);
226
- toString(): string;
275
+ protected getTypeString(): string;
276
+ /**
277
+ * @privateRemarks
278
+ * An argument could be made that this ought to return true for indexedObject
279
+ * since precedence is different than on the value side... if someone really cares
280
+ * they can easily use a custom theme to change this.
281
+ */
282
+ needsParenthesis(): boolean;
227
283
  }
228
284
  /**
229
285
  * Represents a type that refers to another reflection like a class, interface or enum.
@@ -274,7 +330,8 @@ export declare class ReferenceType extends Type {
274
330
  static createSymbolReference(symbol: ts.Symbol, context: Context, name?: string): ReferenceType;
275
331
  /** @internal this is used for type parameters, which don't actually point to something */
276
332
  static createBrokenReference(name: string, project: ProjectReflection): ReferenceType;
277
- toString(): string;
333
+ protected getTypeString(): string;
334
+ needsParenthesis(): boolean;
278
335
  }
279
336
  /**
280
337
  * Represents a type which has it's own reflection like literal types.
@@ -290,7 +347,8 @@ export declare class ReflectionType extends Type {
290
347
  readonly type = "reflection";
291
348
  declaration: DeclarationReflection;
292
349
  constructor(declaration: DeclarationReflection);
293
- toString(): "Function" | "Object";
350
+ protected getTypeString(): "Function" | "Object";
351
+ needsParenthesis(): boolean;
294
352
  }
295
353
  /**
296
354
  * Represents a rest type
@@ -303,7 +361,8 @@ export declare class RestType extends Type {
303
361
  elementType: Type;
304
362
  readonly type = "rest";
305
363
  constructor(elementType: Type);
306
- toString(): string;
364
+ protected getTypeString(): string;
365
+ needsParenthesis(): boolean;
307
366
  }
308
367
  /**
309
368
  * TS 4.1 template literal types
@@ -316,7 +375,8 @@ export declare class TemplateLiteralType extends Type {
316
375
  tail: [Type, string][];
317
376
  readonly type = "template-literal";
318
377
  constructor(head: string, tail: [Type, string][]);
319
- toString(): string;
378
+ protected getTypeString(): string;
379
+ needsParenthesis(): boolean;
320
380
  }
321
381
  /**
322
382
  * Represents a tuple type.
@@ -332,7 +392,8 @@ export declare class TupleType extends Type {
332
392
  */
333
393
  elements: Type[];
334
394
  constructor(elements: Type[]);
335
- toString(): string;
395
+ protected getTypeString(): string;
396
+ needsParenthesis(): boolean;
336
397
  }
337
398
  /**
338
399
  * Represents a named member of a tuple type.
@@ -350,7 +411,8 @@ export declare class NamedTupleMember extends Type {
350
411
  /**
351
412
  * Return a string representation of this type.
352
413
  */
353
- toString(): string;
414
+ protected getTypeString(): string;
415
+ needsParenthesis(): boolean;
354
416
  }
355
417
  /**
356
418
  * Represents a type operator type.
@@ -365,7 +427,8 @@ export declare class TypeOperatorType extends Type {
365
427
  operator: "keyof" | "unique" | "readonly";
366
428
  readonly type = "typeOperator";
367
429
  constructor(target: Type, operator: "keyof" | "unique" | "readonly");
368
- toString(): string;
430
+ protected getTypeString(): string;
431
+ needsParenthesis(context: TypeContext): boolean;
369
432
  }
370
433
  /**
371
434
  * Represents an union type.
@@ -378,7 +441,8 @@ export declare class UnionType extends Type {
378
441
  types: SomeType[];
379
442
  readonly type = "union";
380
443
  constructor(types: SomeType[]);
381
- toString(): string;
444
+ protected getTypeString(): string;
445
+ needsParenthesis(context: TypeContext): boolean;
382
446
  private normalize;
383
447
  }
384
448
  /**
@@ -391,5 +455,10 @@ export declare class UnknownType extends Type {
391
455
  */
392
456
  name: string;
393
457
  constructor(name: string);
394
- toString(): string;
458
+ protected getTypeString(): string;
459
+ /**
460
+ * Always returns true if not at the root level, we have no idea what's in here, so wrap it in parenthesis
461
+ * to be extra safe.
462
+ */
463
+ needsParenthesis(context: TypeContext): boolean;
395
464
  }