typedoc 0.23.24 → 0.23.26

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 (70) hide show
  1. package/dist/index.d.ts +2 -2
  2. package/dist/index.js +5 -2
  3. package/dist/lib/application-events.d.ts +1 -0
  4. package/dist/lib/application-events.js +1 -0
  5. package/dist/lib/application.d.ts +5 -2
  6. package/dist/lib/application.js +44 -14
  7. package/dist/lib/converter/comments/discovery.d.ts +1 -1
  8. package/dist/lib/converter/comments/discovery.js +77 -74
  9. package/dist/lib/converter/comments/index.d.ts +1 -1
  10. package/dist/lib/converter/comments/index.js +22 -19
  11. package/dist/lib/converter/comments/linkResolver.d.ts +7 -2
  12. package/dist/lib/converter/comments/linkResolver.js +28 -17
  13. package/dist/lib/converter/context.d.ts +2 -2
  14. package/dist/lib/converter/context.js +6 -3
  15. package/dist/lib/converter/convert-expression.d.ts +1 -1
  16. package/dist/lib/converter/convert-expression.js +16 -13
  17. package/dist/lib/converter/converter.d.ts +6 -4
  18. package/dist/lib/converter/converter.js +18 -14
  19. package/dist/lib/converter/factories/index-signature.d.ts +1 -1
  20. package/dist/lib/converter/factories/index-signature.js +8 -5
  21. package/dist/lib/converter/factories/signature.d.ts +1 -1
  22. package/dist/lib/converter/factories/signature.js +32 -29
  23. package/dist/lib/converter/index.d.ts +1 -0
  24. package/dist/lib/converter/jsdoc.d.ts +1 -1
  25. package/dist/lib/converter/jsdoc.js +18 -15
  26. package/dist/lib/converter/plugins/CommentPlugin.d.ts +2 -0
  27. package/dist/lib/converter/plugins/CommentPlugin.js +19 -4
  28. package/dist/lib/converter/plugins/ImplementsPlugin.js +10 -7
  29. package/dist/lib/converter/plugins/LinkResolverPlugin.js +10 -2
  30. package/dist/lib/converter/plugins/PackagePlugin.js +25 -2
  31. package/dist/lib/converter/plugins/SourcePlugin.js +7 -4
  32. package/dist/lib/converter/symbols.d.ts +1 -1
  33. package/dist/lib/converter/symbols.js +129 -126
  34. package/dist/lib/converter/types.d.ts +1 -1
  35. package/dist/lib/converter/types.js +101 -98
  36. package/dist/lib/converter/utils/base-path.js +24 -1
  37. package/dist/lib/converter/utils/nodes.d.ts +1 -1
  38. package/dist/lib/converter/utils/nodes.js +5 -2
  39. package/dist/lib/converter/utils/symbols.d.ts +1 -1
  40. package/dist/lib/converter/utils/symbols.js +5 -2
  41. package/dist/lib/models/comments/comment.d.ts +6 -0
  42. package/dist/lib/models/comments/comment.js +50 -0
  43. package/dist/lib/output/components.js +24 -1
  44. package/dist/lib/output/events.js +24 -1
  45. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +24 -1
  46. package/dist/lib/output/renderer.js +25 -2
  47. package/dist/lib/output/themes/MarkedPlugin.js +26 -3
  48. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +2 -2
  49. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +2 -2
  50. package/dist/lib/output/themes/lib.d.ts +1 -3
  51. package/dist/lib/output/themes/lib.js +1 -41
  52. package/dist/lib/serialization/index.js +24 -1
  53. package/dist/lib/utils/entry-point.d.ts +1 -1
  54. package/dist/lib/utils/entry-point.js +35 -9
  55. package/dist/lib/utils/fs.js +33 -3
  56. package/dist/lib/utils/general.js +24 -1
  57. package/dist/lib/utils/highlighter.js +24 -1
  58. package/dist/lib/utils/index.js +14 -2
  59. package/dist/lib/utils/loggers.d.ts +1 -1
  60. package/dist/lib/utils/loggers.js +9 -6
  61. package/dist/lib/utils/options/declaration.d.ts +1 -0
  62. package/dist/lib/utils/options/readers/tsconfig.js +8 -5
  63. package/dist/lib/utils/options/readers/typedoc.d.ts +1 -1
  64. package/dist/lib/utils/options/readers/typedoc.js +39 -5
  65. package/dist/lib/utils/options/sources/typedoc.js +79 -11
  66. package/dist/lib/utils/plugins.js +25 -2
  67. package/dist/lib/validation/documentation.js +13 -1
  68. package/dist/lib/validation/exports.js +5 -2
  69. package/package.json +12 -12
  70. package/static/main.js +1 -1
@@ -1,13 +1,16 @@
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.resolvePartLinks = exports.resolveLinks = void 0;
4
- const ts = require("typescript");
7
+ const typescript_1 = __importDefault(require("typescript"));
5
8
  const models_1 = require("../../models");
6
9
  const declarationReference_1 = require("./declarationReference");
7
10
  const declarationReferenceResolver_1 = require("./declarationReferenceResolver");
8
11
  const urlPrefix = /^(http|ftp)s?:\/\//;
9
12
  const brackets = /\[\[(?!include:)([^\]]+)\]\]/g;
10
- function resolveLinks(comment, reflection, validation, logger, attemptExternalResolve) {
13
+ function resolveLinks(comment, reflection, validation, logger, externalResolver) {
11
14
  let warned = false;
12
15
  const warn = () => {
13
16
  if (!warned) {
@@ -15,20 +18,20 @@ function resolveLinks(comment, reflection, validation, logger, attemptExternalRe
15
18
  logger.warn(`${reflection.getFriendlyFullName()}: Comment [[target]] style links are deprecated and will be removed in 0.24`);
16
19
  }
17
20
  };
18
- comment.summary = resolvePartLinks(reflection, comment.summary, warn, validation, logger, attemptExternalResolve);
21
+ comment.summary = resolvePartLinks(reflection, comment.summary, warn, validation, logger, externalResolver);
19
22
  for (const tag of comment.blockTags) {
20
- tag.content = resolvePartLinks(reflection, tag.content, warn, validation, logger, attemptExternalResolve);
23
+ tag.content = resolvePartLinks(reflection, tag.content, warn, validation, logger, externalResolver);
21
24
  }
22
25
  if (reflection instanceof models_1.DeclarationReflection && reflection.readme) {
23
- reflection.readme = resolvePartLinks(reflection, reflection.readme, warn, validation, logger, attemptExternalResolve);
26
+ reflection.readme = resolvePartLinks(reflection, reflection.readme, warn, validation, logger, externalResolver);
24
27
  }
25
28
  }
26
29
  exports.resolveLinks = resolveLinks;
27
- function resolvePartLinks(reflection, parts, warn, validation, logger, attemptExternalResolve) {
28
- return parts.flatMap((part) => processPart(reflection, part, warn, validation, logger, attemptExternalResolve));
30
+ function resolvePartLinks(reflection, parts, warn, validation, logger, externalResolver) {
31
+ return parts.flatMap((part) => processPart(reflection, part, warn, validation, logger, externalResolver));
29
32
  }
30
33
  exports.resolvePartLinks = resolvePartLinks;
31
- function processPart(reflection, part, warn, validation, logger, attemptExternalResolve) {
34
+ function processPart(reflection, part, warn, validation, logger, externalResolver) {
32
35
  if (part.kind === "text" && brackets.test(part.text)) {
33
36
  warn();
34
37
  return replaceBrackets(reflection, part.text, validation, logger);
@@ -37,7 +40,7 @@ function processPart(reflection, part, warn, validation, logger, attemptExternal
37
40
  if (part.tag === "@link" ||
38
41
  part.tag === "@linkcode" ||
39
42
  part.tag === "@linkplain") {
40
- return resolveLinkTag(reflection, part, attemptExternalResolve, (msg) => {
43
+ return resolveLinkTag(reflection, part, externalResolver, (msg) => {
41
44
  if (validation.invalidLink) {
42
45
  logger.warn(msg);
43
46
  }
@@ -46,17 +49,17 @@ function processPart(reflection, part, warn, validation, logger, attemptExternal
46
49
  }
47
50
  return part;
48
51
  }
49
- function resolveLinkTag(reflection, part, attemptExternalResolve, warn) {
52
+ function resolveLinkTag(reflection, part, externalResolver, warn) {
50
53
  let pos = 0;
51
54
  const end = part.text.length;
52
- while (pos < end && ts.isWhiteSpaceLike(part.text.charCodeAt(pos))) {
55
+ while (pos < end && typescript_1.default.isWhiteSpaceLike(part.text.charCodeAt(pos))) {
53
56
  pos++;
54
57
  }
55
58
  const origText = part.text;
56
59
  // Try to parse one
57
60
  const declRef = (0, declarationReference_1.parseDeclarationReference)(part.text, pos, end);
58
61
  let target;
59
- let defaultDisplayText;
62
+ let defaultDisplayText = "";
60
63
  if (declRef) {
61
64
  // Got one, great! Try to resolve the link
62
65
  target = (0, declarationReferenceResolver_1.resolveDeclarationReference)(reflection, declRef[0]);
@@ -66,9 +69,16 @@ function resolveLinkTag(reflection, part, attemptExternalResolve, warn) {
66
69
  }
67
70
  else {
68
71
  // If we didn't find a link, it might be a @link tag to an external symbol, check that next.
69
- target = attemptExternalResolve(declRef[0]);
70
- if (target) {
71
- defaultDisplayText = part.text.substring(0, pos);
72
+ const externalResolveResult = externalResolver(declRef[0], reflection, part);
73
+ defaultDisplayText = part.text.substring(0, pos);
74
+ switch (typeof externalResolveResult) {
75
+ case "string":
76
+ target = externalResolveResult;
77
+ break;
78
+ case "object":
79
+ target = externalResolveResult.target;
80
+ defaultDisplayText =
81
+ externalResolveResult.caption || defaultDisplayText;
72
82
  }
73
83
  }
74
84
  }
@@ -92,14 +102,15 @@ function resolveLinkTag(reflection, part, attemptExternalResolve, warn) {
92
102
  }
93
103
  // Remaining text after an optional pipe is the link text, so advance
94
104
  // until that's consumed.
95
- while (pos < end && ts.isWhiteSpaceLike(part.text.charCodeAt(pos))) {
105
+ while (pos < end && typescript_1.default.isWhiteSpaceLike(part.text.charCodeAt(pos))) {
96
106
  pos++;
97
107
  }
98
108
  if (pos < end && part.text[pos] === "|") {
99
109
  pos++;
100
110
  }
101
111
  part.target = target;
102
- part.text = part.text.substring(pos).trim() || defaultDisplayText;
112
+ part.text =
113
+ part.text.substring(pos).trim() || defaultDisplayText || part.text;
103
114
  return part;
104
115
  }
105
116
  function legacyResolveLinkTag(reflection, part) {
@@ -1,4 +1,4 @@
1
- import * as ts from "typescript";
1
+ import ts from "typescript";
2
2
  import { Reflection, ProjectReflection, DeclarationReflection, ReflectionKind } from "../models/index";
3
3
  import type { Converter } from "./converter";
4
4
  /**
@@ -46,7 +46,7 @@ export declare class Context {
46
46
  */
47
47
  constructor(converter: Converter, programs: readonly ts.Program[], project: ProjectReflection, scope?: Context["scope"]);
48
48
  /** @internal */
49
- get logger(): import("../utils").Logger;
49
+ get logger(): import("../utils/loggers").Logger;
50
50
  /**
51
51
  * Return the compiler options.
52
52
  */
@@ -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.Context = void 0;
4
7
  const assert_1 = require("assert");
5
- const ts = require("typescript");
8
+ const typescript_1 = __importDefault(require("typescript"));
6
9
  const index_1 = require("../models/index");
7
10
  const nodes_1 = require("./utils/nodes");
8
11
  const converter_events_1 = require("./converter-events");
@@ -96,8 +99,8 @@ class Context {
96
99
  expectSymbolAtLocation(node) {
97
100
  const symbol = this.getSymbolAtLocation(node);
98
101
  if (!symbol) {
99
- const { line } = ts.getLineAndCharacterOfPosition(node.getSourceFile(), node.pos);
100
- throw new Error(`Expected a symbol for node with kind ${ts.SyntaxKind[node.kind]} at ${node.getSourceFile().fileName}:${line + 1}`);
102
+ const { line } = typescript_1.default.getLineAndCharacterOfPosition(node.getSourceFile(), node.pos);
103
+ throw new Error(`Expected a symbol for node with kind ${typescript_1.default.SyntaxKind[node.kind]} at ${node.getSourceFile().fileName}:${line + 1}`);
101
104
  }
102
105
  return symbol;
103
106
  }
@@ -1,4 +1,4 @@
1
- import * as ts from "typescript";
1
+ import ts from "typescript";
2
2
  /**
3
3
  * Return the default value of the given node.
4
4
  *
@@ -1,7 +1,10 @@
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.convertExpression = exports.convertDefaultValue = void 0;
4
- const ts = require("typescript");
7
+ const typescript_1 = __importDefault(require("typescript"));
5
8
  /**
6
9
  * Return the default value of the given node.
7
10
  *
@@ -20,32 +23,32 @@ function convertDefaultValue(node) {
20
23
  exports.convertDefaultValue = convertDefaultValue;
21
24
  function convertExpression(expression) {
22
25
  switch (expression.kind) {
23
- case ts.SyntaxKind.StringLiteral:
24
- case ts.SyntaxKind.TrueKeyword:
25
- case ts.SyntaxKind.FalseKeyword:
26
- case ts.SyntaxKind.NullKeyword:
27
- case ts.SyntaxKind.NumericLiteral:
28
- case ts.SyntaxKind.PrefixUnaryExpression:
29
- case ts.SyntaxKind.Identifier:
26
+ case typescript_1.default.SyntaxKind.StringLiteral:
27
+ case typescript_1.default.SyntaxKind.TrueKeyword:
28
+ case typescript_1.default.SyntaxKind.FalseKeyword:
29
+ case typescript_1.default.SyntaxKind.NullKeyword:
30
+ case typescript_1.default.SyntaxKind.NumericLiteral:
31
+ case typescript_1.default.SyntaxKind.PrefixUnaryExpression:
32
+ case typescript_1.default.SyntaxKind.Identifier:
30
33
  return expression.getText();
31
34
  }
32
- if (ts.isArrayLiteralExpression(expression) &&
35
+ if (typescript_1.default.isArrayLiteralExpression(expression) &&
33
36
  expression.elements.length === 0) {
34
37
  return "[]";
35
38
  }
36
- if (ts.isObjectLiteralExpression(expression) &&
39
+ if (typescript_1.default.isObjectLiteralExpression(expression) &&
37
40
  expression.properties.length === 0) {
38
41
  return "{}";
39
42
  }
40
43
  // a.b.c.d
41
- if (ts.isPropertyAccessExpression(expression)) {
44
+ if (typescript_1.default.isPropertyAccessExpression(expression)) {
42
45
  const parts = [expression.name.getText()];
43
46
  let iter = expression.expression;
44
- while (ts.isPropertyAccessExpression(iter)) {
47
+ while (typescript_1.default.isPropertyAccessExpression(iter)) {
45
48
  parts.unshift(iter.name.getText());
46
49
  iter = iter.expression;
47
50
  }
48
- if (ts.isIdentifier(iter)) {
51
+ if (typescript_1.default.isIdentifier(iter)) {
49
52
  parts.unshift(iter.text);
50
53
  return parts.join(".");
51
54
  }
@@ -1,4 +1,4 @@
1
- import * as ts from "typescript";
1
+ import ts from "typescript";
2
2
  import type { Application } from "../application";
3
3
  import { Comment, CommentDisplayPart, ProjectReflection, Reflection, SomeType } from "../models/index";
4
4
  import { Context } from "./context";
@@ -8,6 +8,7 @@ import { MinimalSourceFile } from "../utils";
8
8
  import type { DocumentationEntryPoint } from "../utils/entry-point";
9
9
  import { CommentParserConfig } from "./comments";
10
10
  import type { CommentStyle, ValidationOptions } from "../utils/options/declaration";
11
+ import { ExternalSymbolResolver, ExternalResolveResult } from "./comments/linkResolver";
11
12
  import type { DeclarationReference } from "./comments/declarationReference";
12
13
  /**
13
14
  * Compiles source files using TypeScript and converts compiler symbols to reflections.
@@ -128,12 +129,13 @@ export declare class Converter extends ChildableComponent<Application, Converter
128
129
  *
129
130
  * Note: This will be used for both references to types declared in node_modules (in which case the
130
131
  * reference passed will have the `moduleSource` set and the `symbolReference` will navigate via `.`)
131
- * and user defined \{\@link\} tags which cannot be resolved.
132
+ * and user defined \{\@link\} tags which cannot be resolved. If the link being resolved is inferred
133
+ * from a type, then no `part` will be passed to the resolver function.
132
134
  * @since 0.22.14
133
135
  */
134
- addUnknownSymbolResolver(resolver: (ref: DeclarationReference) => string | undefined): void;
136
+ addUnknownSymbolResolver(resolver: ExternalSymbolResolver): void;
135
137
  /** @internal */
136
- resolveExternalLink(ref: DeclarationReference): string | undefined;
138
+ resolveExternalLink(ref: DeclarationReference, refl: Reflection, part?: CommentDisplayPart): ExternalResolveResult | string | undefined;
137
139
  resolveLinks(comment: Comment, owner: Reflection): void;
138
140
  resolveLinks(parts: readonly CommentDisplayPart[], owner: Reflection): CommentDisplayPart[];
139
141
  /**
@@ -5,10 +5,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
8
11
  var Converter_1;
9
12
  Object.defineProperty(exports, "__esModule", { value: true });
10
13
  exports.Converter = void 0;
11
- const ts = require("typescript");
14
+ const typescript_1 = __importDefault(require("typescript"));
12
15
  const index_1 = require("../models/index");
13
16
  const context_1 = require("./context");
14
17
  const components_1 = require("./components");
@@ -104,23 +107,24 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
104
107
  *
105
108
  * Note: This will be used for both references to types declared in node_modules (in which case the
106
109
  * reference passed will have the `moduleSource` set and the `symbolReference` will navigate via `.`)
107
- * and user defined \{\@link\} tags which cannot be resolved.
110
+ * and user defined \{\@link\} tags which cannot be resolved. If the link being resolved is inferred
111
+ * from a type, then no `part` will be passed to the resolver function.
108
112
  * @since 0.22.14
109
113
  */
110
114
  addUnknownSymbolResolver(resolver) {
111
115
  this._externalSymbolResolvers.push(resolver);
112
116
  }
113
117
  /** @internal */
114
- resolveExternalLink(ref) {
118
+ resolveExternalLink(ref, refl, part) {
115
119
  for (const resolver of this._externalSymbolResolvers) {
116
- const resolved = resolver(ref);
120
+ const resolved = resolver(ref, refl, part);
117
121
  if (resolved)
118
122
  return resolved;
119
123
  }
120
124
  }
121
125
  resolveLinks(comment, owner) {
122
126
  if (comment instanceof index_1.Comment) {
123
- (0, linkResolver_1.resolveLinks)(comment, owner, this.validation, this.owner.logger, (ref) => this.resolveExternalLink(ref));
127
+ (0, linkResolver_1.resolveLinks)(comment, owner, this.validation, this.owner.logger, (ref, part, refl) => this.resolveExternalLink(ref, part, refl));
124
128
  }
125
129
  else {
126
130
  let warned = false;
@@ -130,7 +134,7 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
130
134
  this.application.logger.warn(`${owner.name}: Comment [[target]] style links are deprecated and will be removed in 0.24`);
131
135
  }
132
136
  };
133
- return (0, linkResolver_1.resolvePartLinks)(owner, comment, warn, this.validation, this.owner.logger, (ref) => this.resolveExternalLink(ref));
137
+ return (0, linkResolver_1.resolvePartLinks)(owner, comment, warn, this.validation, this.owner.logger, (ref, part, refl) => this.resolveExternalLink(ref, part, refl));
134
138
  }
135
139
  }
136
140
  /**
@@ -356,15 +360,15 @@ function getSymbolForModuleLike(context, node) {
356
360
  // "globals" file, but this is uncommon enough that I'm skipping it for now.
357
361
  const sourceFile = node.getSourceFile();
358
362
  const globalSymbols = context.checker
359
- .getSymbolsInScope(node, ts.SymbolFlags.ModuleMember)
363
+ .getSymbolsInScope(node, typescript_1.default.SymbolFlags.ModuleMember)
360
364
  .filter((s) => s.getDeclarations()?.some((d) => d.getSourceFile() === sourceFile));
361
365
  // Detect declaration files with declare module "foo" as their only export
362
366
  // and lift that up one level as the source file symbol
363
367
  if (globalSymbols.length === 1 &&
364
368
  globalSymbols[0]
365
369
  .getDeclarations()
366
- ?.every((declaration) => ts.isModuleDeclaration(declaration) &&
367
- ts.isStringLiteral(declaration.name))) {
370
+ ?.every((declaration) => typescript_1.default.isModuleDeclaration(declaration) &&
371
+ typescript_1.default.isStringLiteral(declaration.name))) {
368
372
  return globalSymbols[0];
369
373
  }
370
374
  }
@@ -379,15 +383,15 @@ function getExports(context, node, symbol) {
379
383
  // members of the export= class and as functions if a class is directly exported.
380
384
  result = [exportEq].concat(context.checker
381
385
  .getExportsOfModule(symbol)
382
- .filter((s) => !(0, enum_1.hasAnyFlag)(s.flags, ts.SymbolFlags.Prototype | ts.SymbolFlags.Value)));
386
+ .filter((s) => !(0, enum_1.hasAnyFlag)(s.flags, typescript_1.default.SymbolFlags.Prototype | typescript_1.default.SymbolFlags.Value)));
383
387
  }
384
388
  else if (symbol) {
385
389
  result = context.checker
386
390
  .getExportsOfModule(symbol)
387
- .filter((s) => !(0, enum_1.hasAllFlags)(s.flags, ts.SymbolFlags.Prototype));
391
+ .filter((s) => !(0, enum_1.hasAllFlags)(s.flags, typescript_1.default.SymbolFlags.Prototype));
388
392
  if (result.length === 0) {
389
- const globalDecl = node.statements.find((s) => ts.isModuleDeclaration(s) &&
390
- s.flags & ts.NodeFlags.GlobalAugmentation);
393
+ const globalDecl = node.statements.find((s) => typescript_1.default.isModuleDeclaration(s) &&
394
+ s.flags & typescript_1.default.NodeFlags.GlobalAugmentation);
391
395
  if (globalDecl) {
392
396
  const globalSymbol = context.getSymbolAtLocation(globalDecl);
393
397
  if (globalSymbol) {
@@ -402,7 +406,7 @@ function getExports(context, node, symbol) {
402
406
  // Global file with no inferred top level symbol, get all symbols declared in this file.
403
407
  const sourceFile = node.getSourceFile();
404
408
  result = context.checker
405
- .getSymbolsInScope(node, ts.SymbolFlags.ModuleMember)
409
+ .getSymbolsInScope(node, typescript_1.default.SymbolFlags.ModuleMember)
406
410
  .filter((s) => s
407
411
  .getDeclarations()
408
412
  ?.some((d) => d.getSourceFile() === sourceFile));
@@ -1,3 +1,3 @@
1
- import * as ts from "typescript";
1
+ import ts from "typescript";
2
2
  import type { Context } from "../context";
3
3
  export declare function convertIndexSignature(context: Context, symbol: ts.Symbol): void;
@@ -1,21 +1,24 @@
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.convertIndexSignature = void 0;
4
- const assert = require("assert");
5
- const ts = require("typescript");
7
+ const assert_1 = __importDefault(require("assert"));
8
+ const typescript_1 = __importDefault(require("typescript"));
6
9
  const models_1 = require("../../models");
7
10
  const converter_events_1 = require("../converter-events");
8
11
  function convertIndexSignature(context, symbol) {
9
- assert(context.scope instanceof models_1.DeclarationReflection);
12
+ (0, assert_1.default)(context.scope instanceof models_1.DeclarationReflection);
10
13
  const indexSymbol = symbol.members?.get("__index");
11
14
  if (indexSymbol) {
12
15
  // Right now TypeDoc models don't have a way to distinguish between string
13
16
  // and number index signatures... { [x: string]: 1 | 2; [x: number]: 2 }
14
17
  // will be misrepresented.
15
18
  const indexDeclaration = indexSymbol.getDeclarations()?.[0];
16
- assert(indexDeclaration && ts.isIndexSignatureDeclaration(indexDeclaration));
19
+ (0, assert_1.default)(indexDeclaration && typescript_1.default.isIndexSignatureDeclaration(indexDeclaration));
17
20
  const param = indexDeclaration.parameters[0];
18
- assert(param && ts.isParameter(param));
21
+ (0, assert_1.default)(param && typescript_1.default.isParameter(param));
19
22
  const index = new models_1.SignatureReflection("__index", models_1.ReflectionKind.IndexSignature, context.scope);
20
23
  index.parameters = [
21
24
  new models_1.ParameterReflection(param.name.getText(), models_1.ReflectionKind.Parameter, index),
@@ -1,4 +1,4 @@
1
- import * as ts from "typescript";
1
+ import ts from "typescript";
2
2
  import { ParameterReflection, ReflectionKind, SignatureReflection, TypeParameterReflection } from "../../models";
3
3
  import type { Context } from "../context";
4
4
  export declare function createSignature(context: Context, kind: ReflectionKind.CallSignature | ReflectionKind.ConstructorSignature | ReflectionKind.GetSignature | ReflectionKind.SetSignature, signature: ts.Signature, declaration?: ts.SignatureDeclaration | ts.JSDocSignature): void;
@@ -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.createTypeParamReflection = exports.convertTypeParameterNodes = exports.convertParameterNodes = exports.createSignature = void 0;
4
- const ts = require("typescript");
5
- const assert = require("assert");
7
+ const typescript_1 = __importDefault(require("typescript"));
8
+ const assert_1 = __importDefault(require("assert"));
6
9
  const models_1 = require("../../models");
7
10
  const converter_events_1 = require("../converter-events");
8
11
  const convert_expression_1 = require("../convert-expression");
@@ -10,7 +13,7 @@ const reflections_1 = require("../utils/reflections");
10
13
  const comments_1 = require("../comments");
11
14
  function createSignature(context, kind, signature, declaration) {
12
15
  var _a;
13
- assert(context.scope instanceof models_1.DeclarationReflection);
16
+ (0, assert_1.default)(context.scope instanceof models_1.DeclarationReflection);
14
17
  declaration || (declaration = signature.getDeclaration());
15
18
  const sigRef = new models_1.SignatureReflection(kind == models_1.ReflectionKind.ConstructorSignature
16
19
  ? `new ${context.scope.parent.name}`
@@ -42,7 +45,7 @@ function createSignature(context, kind, signature, declaration) {
42
45
  sigRef.type = new models_1.IntrinsicType("void");
43
46
  }
44
47
  else {
45
- sigRef.type = context.converter.convertType(context.withScope(sigRef), (declaration?.kind === ts.SyntaxKind.FunctionDeclaration &&
48
+ sigRef.type = context.converter.convertType(context.withScope(sigRef), (declaration?.kind === typescript_1.default.SyntaxKind.FunctionDeclaration &&
46
49
  declaration.type) ||
47
50
  signature.getReturnType());
48
51
  }
@@ -66,11 +69,11 @@ exports.createSignature = createSignature;
66
69
  function convertParameters(context, sigRef, parameters, parameterNodes) {
67
70
  return parameters.map((param, i) => {
68
71
  const declaration = param.valueDeclaration;
69
- assert(!declaration ||
70
- ts.isParameter(declaration) ||
71
- ts.isJSDocParameterTag(declaration));
72
+ (0, assert_1.default)(!declaration ||
73
+ typescript_1.default.isParameter(declaration) ||
74
+ typescript_1.default.isJSDocParameterTag(declaration));
72
75
  const paramRefl = new models_1.ParameterReflection(/__\d+/.test(param.name) ? "__namedParameters" : param.name, models_1.ReflectionKind.Parameter, sigRef);
73
- if (declaration && ts.isJSDocParameterTag(declaration)) {
76
+ if (declaration && typescript_1.default.isJSDocParameterTag(declaration)) {
74
77
  paramRefl.comment = (0, comments_1.getJsDocComment)(declaration, context.converter.config, context.logger);
75
78
  }
76
79
  paramRefl.comment || (paramRefl.comment = (0, comments_1.getComment)(param, paramRefl.kind, context.converter.config, context.logger, context.converter.commentStyle));
@@ -86,9 +89,9 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
86
89
  paramRefl.type = context.converter.convertType(context.withScope(paramRefl), type);
87
90
  let isOptional = false;
88
91
  if (declaration) {
89
- isOptional = ts.isParameter(declaration)
92
+ isOptional = typescript_1.default.isParameter(declaration)
90
93
  ? !!declaration.questionToken ||
91
- ts
94
+ typescript_1.default
92
95
  .getJSDocParameterTags(declaration)
93
96
  .some((tag) => tag.isBracketed)
94
97
  : declaration.isBracketed;
@@ -102,10 +105,10 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
102
105
  // because the method body uses `arguments`... which is always a rest argument
103
106
  let isRest = true;
104
107
  if (declaration) {
105
- isRest = ts.isParameter(declaration)
108
+ isRest = typescript_1.default.isParameter(declaration)
106
109
  ? !!declaration.dotDotDotToken
107
110
  : !!declaration.typeExpression &&
108
- ts.isJSDocVariadicType(declaration.typeExpression.type);
111
+ typescript_1.default.isJSDocVariadicType(declaration.typeExpression.type);
109
112
  }
110
113
  paramRefl.setFlag(models_1.ReflectionFlag.Rest, isRest);
111
114
  return paramRefl;
@@ -116,13 +119,13 @@ function convertParameterNodes(context, sigRef, parameters) {
116
119
  const paramRefl = new models_1.ParameterReflection(/__\d+/.test(param.name.getText())
117
120
  ? "__namedParameters"
118
121
  : param.name.getText(), models_1.ReflectionKind.Parameter, sigRef);
119
- if (ts.isJSDocParameterTag(param)) {
122
+ if (typescript_1.default.isJSDocParameterTag(param)) {
120
123
  paramRefl.comment = (0, comments_1.getJsDocComment)(param, context.converter.config, context.logger);
121
124
  }
122
125
  context.registerReflection(paramRefl, context.getSymbolAtLocation(param));
123
126
  context.trigger(converter_events_1.ConverterEvents.CREATE_PARAMETER, paramRefl);
124
- paramRefl.type = context.converter.convertType(context.withScope(paramRefl), ts.isParameter(param) ? param.type : param.typeExpression?.type);
125
- const isOptional = ts.isParameter(param)
127
+ paramRefl.type = context.converter.convertType(context.withScope(paramRefl), typescript_1.default.isParameter(param) ? param.type : param.typeExpression?.type);
128
+ const isOptional = typescript_1.default.isParameter(param)
126
129
  ? !!param.questionToken
127
130
  : param.isBracketed;
128
131
  if (isOptional) {
@@ -130,10 +133,10 @@ function convertParameterNodes(context, sigRef, parameters) {
130
133
  }
131
134
  paramRefl.defaultValue = (0, convert_expression_1.convertDefaultValue)(param);
132
135
  paramRefl.setFlag(models_1.ReflectionFlag.Optional, isOptional);
133
- paramRefl.setFlag(models_1.ReflectionFlag.Rest, ts.isParameter(param)
136
+ paramRefl.setFlag(models_1.ReflectionFlag.Rest, typescript_1.default.isParameter(param)
134
137
  ? !!param.dotDotDotToken
135
138
  : !!param.typeExpression &&
136
- ts.isJSDocVariadicType(param.typeExpression.type));
139
+ typescript_1.default.isJSDocVariadicType(param.typeExpression.type));
137
140
  return paramRefl;
138
141
  });
139
142
  }
@@ -150,7 +153,7 @@ function convertTypeParameters(context, parent, parameters) {
150
153
  : void 0;
151
154
  // There's no way to determine directly from a ts.TypeParameter what it's variance modifiers are
152
155
  // so unfortunately we have to go back to the node for this...
153
- const variance = getVariance(param.getSymbol()?.declarations?.find(ts.isTypeParameterDeclaration)
156
+ const variance = getVariance(param.getSymbol()?.declarations?.find(typescript_1.default.isTypeParameterDeclaration)
154
157
  ?.modifiers);
155
158
  const paramRefl = new models_1.TypeParameterReflection(param.symbol.name, constraint, defaultType, parent, variance);
156
159
  context.registerReflection(paramRefl, param.getSymbol());
@@ -171,7 +174,7 @@ function createTypeParamReflection(param, context) {
171
174
  : void 0;
172
175
  const paramRefl = new models_1.TypeParameterReflection(param.name.text, constraint, defaultType, context.scope, getVariance(param.modifiers));
173
176
  context.registerReflection(paramRefl, param.symbol);
174
- if (ts.isJSDocTemplateTag(param.parent)) {
177
+ if (typescript_1.default.isJSDocTemplateTag(param.parent)) {
175
178
  paramRefl.comment = (0, comments_1.getJsDocComment)(param.parent, context.converter.config, context.logger);
176
179
  }
177
180
  context.trigger(converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER, paramRefl, param);
@@ -179,8 +182,8 @@ function createTypeParamReflection(param, context) {
179
182
  }
180
183
  exports.createTypeParamReflection = createTypeParamReflection;
181
184
  function getVariance(modifiers) {
182
- const hasIn = modifiers?.some((mod) => mod.kind === ts.SyntaxKind.InKeyword);
183
- const hasOut = modifiers?.some((mod) => mod.kind === ts.SyntaxKind.OutKeyword);
185
+ const hasIn = modifiers?.some((mod) => mod.kind === typescript_1.default.SyntaxKind.InKeyword);
186
+ const hasOut = modifiers?.some((mod) => mod.kind === typescript_1.default.SyntaxKind.OutKeyword);
184
187
  if (hasIn && hasOut) {
185
188
  return models_1.VarianceModifier.inOut;
186
189
  }
@@ -194,23 +197,23 @@ function getVariance(modifiers) {
194
197
  function convertPredicate(predicate, context) {
195
198
  let name;
196
199
  switch (predicate.kind) {
197
- case ts.TypePredicateKind.This:
198
- case ts.TypePredicateKind.AssertsThis:
200
+ case typescript_1.default.TypePredicateKind.This:
201
+ case typescript_1.default.TypePredicateKind.AssertsThis:
199
202
  name = "this";
200
203
  break;
201
- case ts.TypePredicateKind.Identifier:
202
- case ts.TypePredicateKind.AssertsIdentifier:
204
+ case typescript_1.default.TypePredicateKind.Identifier:
205
+ case typescript_1.default.TypePredicateKind.AssertsIdentifier:
203
206
  name = predicate.parameterName;
204
207
  break;
205
208
  }
206
209
  let asserts;
207
210
  switch (predicate.kind) {
208
- case ts.TypePredicateKind.This:
209
- case ts.TypePredicateKind.Identifier:
211
+ case typescript_1.default.TypePredicateKind.This:
212
+ case typescript_1.default.TypePredicateKind.Identifier:
210
213
  asserts = false;
211
214
  break;
212
- case ts.TypePredicateKind.AssertsThis:
213
- case ts.TypePredicateKind.AssertsIdentifier:
215
+ case typescript_1.default.TypePredicateKind.AssertsThis:
216
+ case typescript_1.default.TypePredicateKind.AssertsIdentifier:
214
217
  asserts = true;
215
218
  break;
216
219
  }
@@ -3,4 +3,5 @@ export { Converter } from "./converter";
3
3
  export type { CommentParserConfig } from "./comments/index";
4
4
  export { convertDefaultValue, convertExpression } from "./convert-expression";
5
5
  export type { DeclarationReference, SymbolReference, ComponentPath, Meaning, MeaningKeyword, } from "./comments/declarationReference";
6
+ export type { ExternalSymbolResolver, ExternalResolveResult, } from "./comments/linkResolver";
6
7
  import "./plugins/index";
@@ -1,4 +1,4 @@
1
- import * as ts from "typescript";
1
+ import ts from "typescript";
2
2
  import type { Context } from "./context";
3
3
  export declare function convertJsDocAlias(context: Context, symbol: ts.Symbol, declaration: ts.JSDocTypedefTag | ts.JSDocEnumTag, exportSymbol?: ts.Symbol): void;
4
4
  export declare function convertJsDocCallback(context: Context, symbol: ts.Symbol, declaration: ts.JSDocCallbackTag, exportSymbol?: ts.Symbol): void;