typedoc 0.24.0 → 0.24.2

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 (66) hide show
  1. package/dist/index.d.ts +2 -3
  2. package/dist/index.js +2 -3
  3. package/dist/lib/application.js +2 -1
  4. package/dist/lib/converter/comments/parser.js +1 -1
  5. package/dist/lib/converter/plugins/ImplementsPlugin.js +16 -6
  6. package/dist/lib/converter/plugins/PackagePlugin.js +1 -1
  7. package/dist/lib/converter/plugins/SourcePlugin.js +2 -3
  8. package/dist/lib/converter/types.js +3 -1
  9. package/dist/lib/models/comments/comment.js +6 -1
  10. package/dist/lib/models/reflections/abstract.d.ts +5 -2
  11. package/dist/lib/models/reflections/abstract.js +0 -11
  12. package/dist/lib/models/reflections/container.d.ts +0 -8
  13. package/dist/lib/models/reflections/container.js +0 -8
  14. package/dist/lib/models/reflections/declaration.d.ts +0 -8
  15. package/dist/lib/models/reflections/declaration.js +0 -8
  16. package/dist/lib/models/reflections/kind.d.ts +2 -0
  17. package/dist/lib/models/reflections/kind.js +5 -0
  18. package/dist/lib/models/reflections/parameter.d.ts +0 -8
  19. package/dist/lib/models/reflections/parameter.js +0 -9
  20. package/dist/lib/models/reflections/project.d.ts +5 -0
  21. package/dist/lib/models/reflections/project.js +40 -9
  22. package/dist/lib/models/reflections/signature.d.ts +0 -8
  23. package/dist/lib/models/reflections/signature.js +0 -9
  24. package/dist/lib/models/reflections/type-parameter.d.ts +2 -1
  25. package/dist/lib/models/reflections/type-parameter.js +3 -0
  26. package/dist/lib/models/types.d.ts +15 -4
  27. package/dist/lib/models/types.js +20 -3
  28. package/dist/lib/output/themes/MarkedPlugin.js +4 -3
  29. package/dist/lib/output/themes/default/DefaultTheme.js +3 -9
  30. package/dist/lib/output/themes/default/layouts/default.js +1 -1
  31. package/dist/lib/output/themes/default/partials/icon.js +1 -1
  32. package/dist/lib/output/themes/default/partials/member.declaration.js +1 -1
  33. package/dist/lib/output/themes/default/partials/member.signature.body.js +1 -1
  34. package/dist/lib/output/themes/default/partials/member.signature.title.d.ts +4 -4
  35. package/dist/lib/output/themes/default/partials/member.signature.title.js +26 -13
  36. package/dist/lib/output/themes/default/partials/navigation.js +1 -1
  37. package/dist/lib/output/themes/default/partials/parameter.js +5 -5
  38. package/dist/lib/output/themes/default/partials/type.js +44 -31
  39. package/dist/lib/output/themes/default/partials/typeParameters.js +1 -1
  40. package/dist/lib/output/themes/lib.d.ts +2 -0
  41. package/dist/lib/output/themes/lib.js +13 -2
  42. package/dist/lib/serialization/schema.d.ts +1 -1
  43. package/dist/lib/serialization/schema.js +0 -1
  44. package/dist/lib/utils/entry-point.js +6 -16
  45. package/dist/lib/utils/fs.d.ts +1 -7
  46. package/dist/lib/utils/fs.js +19 -17
  47. package/dist/lib/utils/html-entities.json +2233 -0
  48. package/dist/lib/utils/html.d.ts +1 -0
  49. package/dist/lib/utils/html.js +28 -0
  50. package/dist/lib/utils/index.d.ts +3 -2
  51. package/dist/lib/utils/index.js +3 -2
  52. package/dist/lib/utils/jsx.js +8 -7
  53. package/dist/lib/utils/map.d.ts +1 -0
  54. package/dist/lib/utils/map.js +3 -0
  55. package/dist/lib/utils/options/declaration.d.ts +30 -29
  56. package/dist/lib/utils/options/index.d.ts +1 -1
  57. package/dist/lib/utils/options/readers/tsconfig.js +2 -2
  58. package/dist/lib/utils/options/readers/typedoc.js +1 -1
  59. package/dist/lib/utils/options/sources/typedoc.js +6 -0
  60. package/dist/lib/utils/paths.d.ts +7 -0
  61. package/dist/lib/utils/paths.js +15 -6
  62. package/dist/lib/utils/sort.d.ts +1 -1
  63. package/dist/lib/utils/sort.js +9 -1
  64. package/package.json +9 -9
  65. package/static/main.js +3 -3
  66. package/static/style.css +217 -91
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export { Application } from "./lib/application";
2
2
  export { EventDispatcher, Event } from "./lib/utils/events";
3
3
  export { resetReflectionID } from "./lib/models/reflections/abstract";
4
- export { normalizePath } from "./lib/utils/fs";
5
4
  /**
6
5
  * All symbols documented under the Models namespace are also available in the root import.
7
6
  */
@@ -10,8 +9,8 @@ export * from "./lib/models";
10
9
  export { Converter, Context, type CommentParserConfig, type DeclarationReference, type SymbolReference, type ComponentPath, type Meaning, type MeaningKeyword, type ExternalResolveResult, type ExternalSymbolResolver, } from "./lib/converter";
11
10
  export { Renderer, DefaultTheme, DefaultThemeRenderContext, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, IndexEvent, } from "./lib/output";
12
11
  export type { RenderTemplate, RendererHooks } from "./lib/output";
13
- export { ArgumentsReader, BindOption, CommentStyle, JSX, LogLevel, Logger, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, } from "./lib/utils";
14
- export type { OptionsReader, TypeDocOptions, TypeDocOptionMap, ValidationOptions, TypeDocOptionValues, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, ObjectDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, SortStrategy, ParameterTypeToOptionTypeMap, DocumentationEntryPoint, ManuallyValidatedOption, EnumKeys, } from "./lib/utils";
12
+ export { ArgumentsReader, BindOption, CommentStyle, JSX, LogLevel, Logger, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, normalizePath, } from "./lib/utils";
13
+ export type { OptionsReader, TypeDocOptions, TypeDocOptionMap, ValidationOptions, TypeDocOptionValues, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, ObjectDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, SortStrategy, ParameterTypeToOptionTypeMap, DocumentationEntryPoint, ManuallyValidatedOption, EnumKeys, JsDocCompatibility, } from "./lib/utils";
15
14
  export type { EventMap, EventCallback } from "./lib/utils/events";
16
15
  export { JSONOutput, Serializer, Deserializer, type Deserializable, type DeserializerComponent, type SerializerComponent, SerializeEvent, } from "./lib/serialization";
17
16
  import TypeScript from "typescript";
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.TypeScript = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.Models = exports.normalizePath = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
32
+ exports.TypeScript = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.normalizePath = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.Models = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
33
33
  var application_1 = require("./lib/application");
34
34
  Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
35
35
  var events_1 = require("./lib/utils/events");
@@ -37,8 +37,6 @@ Object.defineProperty(exports, "EventDispatcher", { enumerable: true, get: funct
37
37
  Object.defineProperty(exports, "Event", { enumerable: true, get: function () { return events_1.Event; } });
38
38
  var abstract_1 = require("./lib/models/reflections/abstract");
39
39
  Object.defineProperty(exports, "resetReflectionID", { enumerable: true, get: function () { return abstract_1.resetReflectionID; } });
40
- var fs_1 = require("./lib/utils/fs");
41
- Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return fs_1.normalizePath; } });
42
40
  /**
43
41
  * All symbols documented under the Models namespace are also available in the root import.
44
42
  */
@@ -73,6 +71,7 @@ Object.defineProperty(exports, "TypeDocReader", { enumerable: true, get: functio
73
71
  Object.defineProperty(exports, "EntryPointStrategy", { enumerable: true, get: function () { return utils_1.EntryPointStrategy; } });
74
72
  Object.defineProperty(exports, "EventHooks", { enumerable: true, get: function () { return utils_1.EventHooks; } });
75
73
  Object.defineProperty(exports, "MinimalSourceFile", { enumerable: true, get: function () { return utils_1.MinimalSourceFile; } });
74
+ Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return utils_1.normalizePath; } });
76
75
  var serialization_1 = require("./lib/serialization");
77
76
  Object.defineProperty(exports, "JSONOutput", { enumerable: true, get: function () { return serialization_1.JSONOutput; } });
78
77
  Object.defineProperty(exports, "Serializer", { enumerable: true, get: function () { return serialization_1.Serializer; } });
@@ -355,6 +355,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
355
355
  this.options = opts;
356
356
  const project = this.convert();
357
357
  if (project) {
358
+ this.validate(project);
358
359
  projects.push(this.serializer.projectToObject(project, process.cwd()));
359
360
  }
360
361
  (0, abstract_1.resetReflectionID)();
@@ -371,7 +372,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
371
372
  }
372
373
  _merge() {
373
374
  const start = Date.now();
374
- const rootDir = (0, fs_1.getCommonDirectory)(this.entryPoints);
375
+ const rootDir = (0, fs_1.deriveRootDir)(this.entryPoints);
375
376
  const entryPoints = this.entryPoints.flatMap((entry) => (0, fs_1.glob)(entry, rootDir));
376
377
  this.logger.verbose(`Merging entry points:\n\t${entryPoints.map(paths_1.nicePath).join("\n\t")}`);
377
378
  if (entryPoints.length < 1) {
@@ -174,7 +174,7 @@ function exampleBlockContent(comment, lexer, config, warning) {
174
174
  const content = blockContent(comment, lexer, config, () => { });
175
175
  const end = lexer.done() || lexer.peek();
176
176
  lexer.release();
177
- if (content.some((part) => part.kind === "code")) {
177
+ if (content.some((part) => part.kind === "code" && part.text.startsWith("```"))) {
178
178
  return blockContent(comment, lexer, config, warning);
179
179
  }
180
180
  const tokens = [];
@@ -17,6 +17,7 @@ const types_1 = require("../../models/types");
17
17
  const array_1 = require("../../utils/array");
18
18
  const components_1 = require("../components");
19
19
  const converter_1 = require("../converter");
20
+ const utils_1 = require("../../utils");
20
21
  /**
21
22
  * A plugin that detects interface implementations of functions and
22
23
  * properties on classes and links them.
@@ -52,13 +53,22 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
52
53
  const interfaceMemberName = interfaceReflection.name + "." + interfaceMember.name;
53
54
  classMember.implementationOf =
54
55
  types_1.ReferenceType.createResolvedReference(interfaceMemberName, interfaceMember, project);
55
- if (interfaceMember.kindOf(index_1.ReflectionKind.FunctionOrMethod) &&
56
- interfaceMember.signatures &&
57
- classMember.signatures) {
58
- for (const [clsSig, intSig] of (0, array_1.zip)(classMember.signatures, interfaceMember.signatures)) {
56
+ const intSigs = interfaceMember.signatures ||
57
+ interfaceMember.type?.visit({
58
+ reflection: (r) => r.declaration.signatures,
59
+ });
60
+ const clsSigs = classMember.signatures ||
61
+ classMember.type?.visit({
62
+ reflection: (r) => r.declaration.signatures,
63
+ });
64
+ if (intSigs && clsSigs) {
65
+ for (const [clsSig, intSig] of (0, array_1.zip)(clsSigs, intSigs)) {
59
66
  if (clsSig.implementationOf) {
67
+ const target = intSig.parent.kindOf(index_1.ReflectionKind.FunctionOrMethod)
68
+ ? intSig
69
+ : intSig.parent.parent;
60
70
  clsSig.implementationOf =
61
- types_1.ReferenceType.createResolvedReference(clsSig.implementationOf.name, intSig, project);
71
+ types_1.ReferenceType.createResolvedReference(clsSig.implementationOf.name, target, project);
62
72
  }
63
73
  }
64
74
  }
@@ -238,7 +248,7 @@ function findProperty(reflection, parent) {
238
248
  }
239
249
  function createLink(context, reflection, clause, expr, symbol, isOverwrite) {
240
250
  const project = context.project;
241
- const name = `${expr.expression.getText()}.${symbol.name}`;
251
+ const name = `${expr.expression.getText()}.${(0, utils_1.getHumanName)(symbol.name)}`;
242
252
  link(reflection);
243
253
  link(reflection.getSignature);
244
254
  link(reflection.setSignature);
@@ -72,7 +72,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
72
72
  const entryFiles = this.entryPointStrategy === utils_1.EntryPointStrategy.Packages
73
73
  ? this.entryPoints.map((d) => (0, path_1.join)(d, "package.json"))
74
74
  : this.entryPoints;
75
- const dirName = Path.resolve((0, fs_1.getCommonDirectory)(entryFiles));
75
+ const dirName = Path.resolve((0, fs_1.deriveRootDir)(entryFiles));
76
76
  this.application.logger.verbose(`Begin readme.md/package.json search at ${(0, paths_1.nicePath)(dirName)}`);
77
77
  this.packageJson = (0, fs_1.discoverPackageJson)(dirName)?.content;
78
78
  // Path will be resolved already. This is kind of ugly, but...
@@ -16,7 +16,6 @@ const components_1 = require("../components");
16
16
  const converter_1 = require("../converter");
17
17
  const utils_1 = require("../../utils");
18
18
  const nodes_1 = require("../utils/nodes");
19
- const fs_1 = require("../../utils/fs");
20
19
  const path_1 = require("path");
21
20
  const models_1 = require("../../models");
22
21
  const repository_1 = require("../utils/repository");
@@ -103,7 +102,7 @@ let SourcePlugin = class SourcePlugin extends components_1.ConverterComponent {
103
102
  onBeginResolve(context) {
104
103
  if (this.disableSources)
105
104
  return;
106
- const basePath = this.basePath || (0, fs_1.getCommonDirectory)([...this.fileNames]);
105
+ const basePath = this.basePath || (0, utils_1.getCommonDirectory)([...this.fileNames]);
107
106
  for (const refl of Object.values(context.project.reflections)) {
108
107
  if (!(refl instanceof index_1.DeclarationReflection ||
109
108
  refl instanceof index_1.SignatureReflection)) {
@@ -114,7 +113,7 @@ let SourcePlugin = class SourcePlugin extends components_1.ConverterComponent {
114
113
  const repo = this.getRepository(source.fullFileName);
115
114
  source.url = repo?.getURL(source.fullFileName, source.line);
116
115
  }
117
- source.fileName = (0, fs_1.normalizePath)((0, path_1.relative)(basePath, source.fullFileName));
116
+ source.fileName = (0, utils_1.normalizePath)((0, path_1.relative)(basePath, source.fullFileName));
118
117
  }
119
118
  }
120
119
  }
@@ -416,7 +416,9 @@ const referenceConverter = {
416
416
  if (!symbol) {
417
417
  // This happens when we get a reference to a type parameter
418
418
  // created within a mapped type, `K` in: `{ [K in T]: string }`
419
- return models_1.ReferenceType.createBrokenReference(context.checker.typeToString(type), context.project);
419
+ const ref = models_1.ReferenceType.createBrokenReference(context.checker.typeToString(type), context.project);
420
+ ref.refersToTypeParameter = true;
421
+ return ref;
420
422
  }
421
423
  const ref = models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context);
422
424
  if (type.flags & typescript_1.default.TypeFlags.StringMapping) {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Comment = exports.CommentTag = void 0;
4
4
  const utils_1 = require("../../utils");
5
+ const kind_1 = require("../reflections/kind");
5
6
  const ReflectionSymbolId_1 = require("../reflections/ReflectionSymbolId");
6
7
  /**
7
8
  * A model that represents a single TypeDoc comment tag.
@@ -88,6 +89,7 @@ class Comment {
88
89
  case "@linkplain": {
89
90
  if (part.target) {
90
91
  let url;
92
+ let kindClass;
91
93
  if (typeof part.target === "string") {
92
94
  url = part.target;
93
95
  }
@@ -95,12 +97,15 @@ class Comment {
95
97
  // No point in trying to resolve a ReflectionSymbolId at this point, we've already
96
98
  // tried and failed during the resolution step.
97
99
  url = urlTo(part.target);
100
+ kindClass = kind_1.ReflectionKind.classString(part.target.kind);
98
101
  }
99
102
  const text = part.tag === "@linkcode"
100
103
  ? `<code>${part.text}</code>`
101
104
  : part.text;
102
105
  result.push(url
103
- ? `<a href="${url}">${text}</a>`
106
+ ? `<a href="${url}"${kindClass
107
+ ? ` class="${kindClass}"`
108
+ : ""}>${text}</a>`
104
109
  : part.text);
105
110
  }
106
111
  else {
@@ -204,14 +204,17 @@ export declare abstract class Reflection {
204
204
  */
205
205
  isDeprecated(): boolean;
206
206
  /**
207
- * Traverse all potential child reflections of this reflection.
207
+ * Traverse most potential child reflections of this reflection.
208
+ *
209
+ * Note: This may not necessarily traverse child reflections contained within the `type` property
210
+ * of the reflection, and should not be relied on for this. Support for checking object types will likely be removed in v0.25.
208
211
  *
209
212
  * The given callback will be invoked for all children, signatures and type parameters
210
213
  * attached to this reflection.
211
214
  *
212
215
  * @param callback The callback function that should be applied for each child reflection.
213
216
  */
214
- traverse(_callback: TraverseCallback): void;
217
+ abstract traverse(callback: TraverseCallback): void;
215
218
  /**
216
219
  * Return a string representation of this reflection.
217
220
  */
@@ -358,17 +358,6 @@ class Reflection {
358
358
  }
359
359
  return this.parent?.isDeprecated() ?? false;
360
360
  }
361
- /**
362
- * Traverse all potential child reflections of this reflection.
363
- *
364
- * The given callback will be invoked for all children, signatures and type parameters
365
- * attached to this reflection.
366
- *
367
- * @param callback The callback function that should be applied for each child reflection.
368
- */
369
- traverse(_callback) {
370
- // do nothing here, overridden by child classes
371
- }
372
361
  /**
373
362
  * Return a string representation of this reflection.
374
363
  */
@@ -24,14 +24,6 @@ export declare abstract class ContainerReflection extends Reflection {
24
24
  * @returns An array containing all children with the desired kind.
25
25
  */
26
26
  getChildrenByKind(kind: ReflectionKind): DeclarationReflection[];
27
- /**
28
- * Traverse all potential child reflections of this reflection.
29
- *
30
- * The given callback will be invoked for all children, signatures and type parameters
31
- * attached to this reflection.
32
- *
33
- * @param callback The callback function that should be applied for each child reflection.
34
- */
35
27
  traverse(callback: TraverseCallback): void;
36
28
  toObject(serializer: Serializer): JSONOutput.ContainerReflection;
37
29
  fromObject(de: Deserializer, obj: JSONOutput.ContainerReflection): void;
@@ -14,14 +14,6 @@ class ContainerReflection extends abstract_1.Reflection {
14
14
  getChildrenByKind(kind) {
15
15
  return (this.children || []).filter((child) => child.kindOf(kind));
16
16
  }
17
- /**
18
- * Traverse all potential child reflections of this reflection.
19
- *
20
- * The given callback will be invoked for all children, signatures and type parameters
21
- * attached to this reflection.
22
- *
23
- * @param callback The callback function that should be applied for each child reflection.
24
- */
25
17
  traverse(callback) {
26
18
  for (const child of this.children?.slice() || []) {
27
19
  if (callback(child, abstract_1.TraverseProperty.Children) === false) {
@@ -148,14 +148,6 @@ export declare class DeclarationReflection extends ContainerReflection {
148
148
  getAllSignatures(): SignatureReflection[];
149
149
  /** @internal */
150
150
  getNonIndexSignatures(): SignatureReflection[];
151
- /**
152
- * Traverse all potential child reflections of this reflection.
153
- *
154
- * The given callback will be invoked for all children, signatures and type parameters
155
- * attached to this reflection.
156
- *
157
- * @param callback The callback function that should be applied for each child reflection.
158
- */
159
151
  traverse(callback: TraverseCallback): void;
160
152
  /**
161
153
  * Return a string representation of this reflection.
@@ -58,14 +58,6 @@ class DeclarationReflection extends container_1.ContainerReflection {
58
58
  getNonIndexSignatures() {
59
59
  return [].concat(this.signatures ?? [], this.setSignature ?? [], this.getSignature ?? []);
60
60
  }
61
- /**
62
- * Traverse all potential child reflections of this reflection.
63
- *
64
- * The given callback will be invoked for all children, signatures and type parameters
65
- * attached to this reflection.
66
- *
67
- * @param callback The callback function that should be applied for each child reflection.
68
- */
69
61
  traverse(callback) {
70
62
  for (const parameter of this.typeParameters?.slice() || []) {
71
63
  if (callback(parameter, abstract_1.TraverseProperty.TypeParameter) === false) {
@@ -24,6 +24,7 @@ export declare enum ReflectionKind {
24
24
  Accessor = 262144,
25
25
  GetSignature = 524288,
26
26
  SetSignature = 1048576,
27
+ /** @deprecated will be removed in v0.25, not used */
27
28
  ObjectLiteral = 2097152,
28
29
  TypeAlias = 4194304,
29
30
  Reference = 8388608
@@ -64,4 +65,5 @@ export declare namespace ReflectionKind {
64
65
  const SignatureContainer: number;
65
66
  function singularString(kind: ReflectionKind): string;
66
67
  function pluralString(kind: ReflectionKind): string;
68
+ function classString(kind: ReflectionKind): string;
67
69
  }
@@ -27,6 +27,7 @@ var ReflectionKind;
27
27
  ReflectionKind[ReflectionKind["Accessor"] = 262144] = "Accessor";
28
28
  ReflectionKind[ReflectionKind["GetSignature"] = 524288] = "GetSignature";
29
29
  ReflectionKind[ReflectionKind["SetSignature"] = 1048576] = "SetSignature";
30
+ /** @deprecated will be removed in v0.25, not used */
30
31
  ReflectionKind[ReflectionKind["ObjectLiteral"] = 2097152] = "ObjectLiteral";
31
32
  ReflectionKind[ReflectionKind["TypeAlias"] = 4194304] = "TypeAlias";
32
33
  ReflectionKind[ReflectionKind["Reference"] = 8388608] = "Reference";
@@ -122,6 +123,10 @@ var ReflectionKind;
122
123
  }
123
124
  }
124
125
  ReflectionKind.pluralString = pluralString;
126
+ function classString(kind) {
127
+ return `tsd-kind-${ReflectionKind[kind].replace(/(.)([A-Z])/g, (_m, a, b) => `${a}-${b}`.toLowerCase())}`;
128
+ }
129
+ ReflectionKind.classString = classString;
125
130
  })(ReflectionKind = exports.ReflectionKind || (exports.ReflectionKind = {}));
126
131
  function getKindString(kind) {
127
132
  return ReflectionKind[kind].replace(/(.)([A-Z])/g, (_m, a, b) => a + " " + b.toLowerCase());
@@ -7,14 +7,6 @@ export declare class ParameterReflection extends Reflection {
7
7
  parent?: SignatureReflection;
8
8
  defaultValue?: string;
9
9
  type?: SomeType;
10
- /**
11
- * Traverse all potential child reflections of this reflection.
12
- *
13
- * The given callback will be invoked for all children, signatures and type parameters
14
- * attached to this reflection.
15
- *
16
- * @param callback The callback function that should be applied for each child reflection.
17
- */
18
10
  traverse(callback: TraverseCallback): void;
19
11
  /**
20
12
  * Return a string representation of this reflection.
@@ -8,21 +8,12 @@ class ParameterReflection extends abstract_1.Reflection {
8
8
  super(...arguments);
9
9
  this.variant = "param";
10
10
  }
11
- /**
12
- * Traverse all potential child reflections of this reflection.
13
- *
14
- * The given callback will be invoked for all children, signatures and type parameters
15
- * attached to this reflection.
16
- *
17
- * @param callback The callback function that should be applied for each child reflection.
18
- */
19
11
  traverse(callback) {
20
12
  if (this.type instanceof types_1.ReflectionType) {
21
13
  if (callback(this.type.declaration, abstract_1.TraverseProperty.TypeLiteral) === false) {
22
14
  return;
23
15
  }
24
16
  }
25
- super.traverse(callback);
26
17
  }
27
18
  /**
28
19
  * Return a string representation of this reflection.
@@ -18,6 +18,7 @@ export declare class ProjectReflection extends ContainerReflection {
18
18
  private reflectionIdToSymbolIdMap;
19
19
  private reflectionIdToSymbolMap;
20
20
  private referenceGraph?;
21
+ private reflectionChildren;
21
22
  /**
22
23
  * A list of all reflections within the project. DO NOT MUTATE THIS OBJECT.
23
24
  * All mutation should be done via {@link registerReflection} and {@link removeReflection}
@@ -63,6 +64,10 @@ export declare class ProjectReflection extends ContainerReflection {
63
64
  * project.
64
65
  */
65
66
  removeReflection(reflection: Reflection): void;
67
+ /**
68
+ * Remove a reflection without updating the parent reflection to remove references to the removed reflection.
69
+ */
70
+ private _removeReflection;
66
71
  /**
67
72
  * Gets the reflection registered for the given reflection ID, or undefined if it is not present
68
73
  * in the project.
@@ -24,6 +24,8 @@ class ProjectReflection extends container_1.ContainerReflection {
24
24
  this.symbolToReflectionIdMap = new map_1.StableKeyMap();
25
25
  this.reflectionIdToSymbolIdMap = new Map();
26
26
  this.reflectionIdToSymbolMap = new Map();
27
+ // Maps a reflection ID to all reflections with it as their parent.
28
+ this.reflectionChildren = new map_1.DefaultMap(() => []);
27
29
  /**
28
30
  * A list of all reflections within the project. DO NOT MUTATE THIS OBJECT.
29
31
  * All mutation should be done via {@link registerReflection} and {@link removeReflection}
@@ -55,6 +57,11 @@ class ProjectReflection extends container_1.ContainerReflection {
55
57
  */
56
58
  registerReflection(reflection, symbol) {
57
59
  this.referenceGraph = undefined;
60
+ if (reflection.parent) {
61
+ this.reflectionChildren
62
+ .get(reflection.parent.id)
63
+ .push(reflection.id);
64
+ }
58
65
  this.reflections[reflection.id] = reflection;
59
66
  if (symbol) {
60
67
  const id = new ReflectionSymbolId_1.ReflectionSymbolId(symbol);
@@ -69,15 +76,13 @@ class ProjectReflection extends container_1.ContainerReflection {
69
76
  * project.
70
77
  */
71
78
  removeReflection(reflection) {
72
- // Remove references
73
- for (const id of this.getReferenceGraph().get(reflection.id) ?? []) {
74
- const ref = this.getReflectionById(id);
75
- if (ref) {
76
- this.removeReflection(ref);
77
- }
78
- }
79
- this.getReferenceGraph().delete(reflection.id);
80
- reflection.traverse((child) => (this.removeReflection(child), true));
79
+ // Remove the reflection...
80
+ this._removeReflection(reflection);
81
+ // And now try to remove references to it in the parent reflection.
82
+ // This might not find anything if someone called removeReflection on a member of a union
83
+ // but I think that could only be caused by a plugin doing something weird, not by a regular
84
+ // user... so this is probably good enough for now. Reflections that live on types are
85
+ // kind of half-real anyways.
81
86
  const parent = reflection.parent;
82
87
  parent?.traverse((child, property) => {
83
88
  if (child !== reflection) {
@@ -109,6 +114,32 @@ class ProjectReflection extends container_1.ContainerReflection {
109
114
  }
110
115
  return false; // Stop iteration
111
116
  });
117
+ }
118
+ /**
119
+ * Remove a reflection without updating the parent reflection to remove references to the removed reflection.
120
+ */
121
+ _removeReflection(reflection) {
122
+ // Remove references pointing to this reflection
123
+ const graph = this.getReferenceGraph();
124
+ for (const id of graph.get(reflection.id) ?? []) {
125
+ const ref = this.getReflectionById(id);
126
+ if (ref) {
127
+ this.removeReflection(ref);
128
+ }
129
+ }
130
+ graph.delete(reflection.id);
131
+ // Remove children of this reflection
132
+ for (const childId of this.reflectionChildren.getNoInsert(reflection.id) || []) {
133
+ const child = this.getReflectionById(childId);
134
+ // Only remove if the child's parent is still actually this reflection.
135
+ // This might not be the case if a plugin has moved this reflection to another parent.
136
+ // (typedoc-plugin-merge-modules)
137
+ if (child?.parent === reflection) {
138
+ this._removeReflection(child);
139
+ }
140
+ }
141
+ this.reflectionChildren.delete(reflection.id);
142
+ // Remove references from the TS symbol to this reflection.
112
143
  const symbol = this.reflectionIdToSymbolMap.get(reflection.id);
113
144
  if (symbol) {
114
145
  const id = new ReflectionSymbolId_1.ReflectionSymbolId(symbol);
@@ -36,14 +36,6 @@ export declare class SignatureReflection extends Reflection {
36
36
  * Applies to class members.
37
37
  */
38
38
  implementationOf?: ReferenceType;
39
- /**
40
- * Traverse all potential child reflections of this reflection.
41
- *
42
- * The given callback will be invoked for all children, signatures and type parameters
43
- * attached to this reflection.
44
- *
45
- * @param callback The callback function that should be applied for each child reflection.
46
- */
47
39
  traverse(callback: TraverseCallback): void;
48
40
  /**
49
41
  * Return a string representation of this reflection.
@@ -9,14 +9,6 @@ class SignatureReflection extends abstract_1.Reflection {
9
9
  super(name, kind, parent);
10
10
  this.variant = "signature";
11
11
  }
12
- /**
13
- * Traverse all potential child reflections of this reflection.
14
- *
15
- * The given callback will be invoked for all children, signatures and type parameters
16
- * attached to this reflection.
17
- *
18
- * @param callback The callback function that should be applied for each child reflection.
19
- */
20
12
  traverse(callback) {
21
13
  if (this.type instanceof types_1.ReflectionType) {
22
14
  if (callback(this.type.declaration, abstract_1.TraverseProperty.TypeLiteral) === false) {
@@ -33,7 +25,6 @@ class SignatureReflection extends abstract_1.Reflection {
33
25
  return;
34
26
  }
35
27
  }
36
- super.traverse(callback);
37
28
  }
38
29
  /**
39
30
  * Return a string representation of this reflection.
@@ -1,5 +1,5 @@
1
1
  import type { SomeType } from "../types";
2
- import { Reflection } from "./abstract";
2
+ import { Reflection, TraverseCallback } from "./abstract";
3
3
  import type { DeclarationReflection } from "./declaration";
4
4
  import type { Serializer, JSONOutput, Deserializer } from "../../serialization";
5
5
  import type { SignatureReflection } from "./signature";
@@ -22,4 +22,5 @@ export declare class TypeParameterReflection extends Reflection {
22
22
  constructor(name: string, parent: Reflection, varianceModifier: VarianceModifier | undefined);
23
23
  toObject(serializer: Serializer): JSONOutput.TypeParameterReflection;
24
24
  fromObject(de: Deserializer, obj: JSONOutput.TypeParameterReflection): void;
25
+ traverse(_callback: TraverseCallback): void;
25
26
  }
@@ -33,5 +33,8 @@ class TypeParameterReflection extends abstract_1.Reflection {
33
33
  this.default = de.reviveType(obj.default);
34
34
  this.varianceModifier = obj.varianceModifier;
35
35
  }
36
+ traverse(_callback) {
37
+ // do nothing, no child reflections.
38
+ }
36
39
  }
37
40
  exports.TypeParameterReflection = TypeParameterReflection;
@@ -216,11 +216,11 @@ export declare class MappedType extends Type {
216
216
  parameter: string;
217
217
  parameterType: SomeType;
218
218
  templateType: SomeType;
219
- readonlyModifier?: "-" | "+" | undefined;
220
- optionalModifier?: "-" | "+" | undefined;
219
+ readonlyModifier?: "+" | "-" | undefined;
220
+ optionalModifier?: "+" | "-" | undefined;
221
221
  nameType?: SomeType | undefined;
222
222
  readonly type = "mapped";
223
- constructor(parameter: string, parameterType: SomeType, templateType: SomeType, readonlyModifier?: "-" | "+" | undefined, optionalModifier?: "-" | "+" | undefined, nameType?: SomeType | undefined);
223
+ constructor(parameter: string, parameterType: SomeType, templateType: SomeType, readonlyModifier?: "+" | "-" | undefined, optionalModifier?: "+" | "-" | undefined, nameType?: SomeType | undefined);
224
224
  protected getTypeString(): string;
225
225
  needsParenthesis(): boolean;
226
226
  toObject(serializer: Serializer): JSONOutput.MappedType;
@@ -343,12 +343,23 @@ export declare class ReferenceType extends Type {
343
343
  * points to the url that this type should be linked to.
344
344
  */
345
345
  externalUrl?: string;
346
+ /**
347
+ * If set, no warnings about something not being exported should be created
348
+ * since this may be referring to a type created with `infer X` which will not
349
+ * be registered on the project.
350
+ */
351
+ refersToTypeParameter: boolean;
346
352
  private _target;
347
353
  private _project;
348
354
  private constructor();
349
355
  static createResolvedReference(name: string, target: Reflection | number, project: ProjectReflection | null): ReferenceType;
350
356
  static createSymbolReference(symbol: ts.Symbol, context: Context, name?: string): ReferenceType;
351
- /** @internal this is used for type parameters, which don't actually point to something */
357
+ /**
358
+ * This is used for type parameters, which don't actually point to something,
359
+ * and also for temporary references which will be cleaned up with real references
360
+ * later during conversion.
361
+ * @internal
362
+ */
352
363
  static createBrokenReference(name: string, project: ProjectReflection): ReferenceType;
353
364
  protected getTypeString(): string;
354
365
  needsParenthesis(): boolean;