typedoc 0.28.2 → 0.28.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/cli.js CHANGED
@@ -20,7 +20,7 @@ async function main() {
20
20
  new td.TypeDocReader(),
21
21
  new td.PackageJsonReader(),
22
22
  new td.TSConfigReader(),
23
- new td.ArgumentsReader(300),
23
+ new td.ArgumentsReader(300).ignoreErrors(),
24
24
  ]);
25
25
  const exitCode = await run(app);
26
26
  if (exitCode !== ExitCodes.Watching) {
@@ -145,7 +145,7 @@ export class Context {
145
145
  reflection.escapedName = symbol?.escapedName ? String(symbol.escapedName) : undefined;
146
146
  this.addChild(reflection);
147
147
  }
148
- if (symbol && this.converter.isExternal(symbol)) {
148
+ if (symbol && this.converter.isExternal(symbol, this.checker)) {
149
149
  reflection.setFlag(ReflectionFlag.External);
150
150
  }
151
151
  if (exportSymbol) {
@@ -188,7 +188,7 @@ export class Context {
188
188
  }
189
189
  }
190
190
  shouldIgnore(symbol) {
191
- return this.converter.shouldIgnore(symbol);
191
+ return this.converter.shouldIgnore(symbol, this.checker);
192
192
  }
193
193
  /**
194
194
  * Register a newly generated reflection. All created reflections should be
@@ -226,10 +226,10 @@ export declare class Converter extends AbstractComponent<Application, ConverterE
226
226
  * information at this point since comment discovery hasn't happened.
227
227
  * @internal
228
228
  */
229
- shouldIgnore(symbol: ts.Symbol): boolean;
229
+ shouldIgnore(symbol: ts.Symbol, checker: ts.TypeChecker): boolean;
230
230
  private isExcluded;
231
231
  /** @internal */
232
- isExternal(symbol: ts.Symbol): boolean;
232
+ isExternal(symbol: ts.Symbol, checker: ts.TypeChecker): boolean;
233
233
  processDocumentTags(reflection: Reflection, parent: ContainerReflection): void;
234
234
  private addDocument;
235
235
  private _buildCommentParserConfig;
@@ -59,6 +59,7 @@ import { SourcePlugin } from "./plugins/SourcePlugin.js";
59
59
  import { TypePlugin } from "./plugins/TypePlugin.js";
60
60
  import { IncludePlugin } from "./plugins/IncludePlugin.js";
61
61
  import { MergeModuleWithPlugin } from "./plugins/MergeModuleWithPlugin.js";
62
+ import { resolveAliasedSymbol } from "./utils/symbols.js";
62
63
  /**
63
64
  * Compiles source files using TypeScript and converts compiler symbols to reflections.
64
65
  *
@@ -310,7 +311,12 @@ let Converter = (() => {
310
311
  this.compile(entryPoints, context);
311
312
  this.resolve(context);
312
313
  this.trigger(Converter.EVENT_END, context);
313
- this._config = undefined;
314
+ // Delete caches of options so that test usage which changes options
315
+ // doesn't have confusing behavior where tests run in isolation work
316
+ // but break when run as a batch.
317
+ delete this._config;
318
+ delete this.excludeCache;
319
+ delete this.externalPatternCache;
314
320
  return project;
315
321
  }
316
322
  /** @internal */
@@ -487,11 +493,12 @@ let Converter = (() => {
487
493
  * information at this point since comment discovery hasn't happened.
488
494
  * @internal
489
495
  */
490
- shouldIgnore(symbol) {
496
+ shouldIgnore(symbol, checker) {
497
+ symbol = resolveAliasedSymbol(symbol, checker);
491
498
  if (this.isExcluded(symbol)) {
492
499
  return true;
493
500
  }
494
- return this.excludeExternals && this.isExternal(symbol);
501
+ return this.excludeExternals && this.isExternal(symbol, checker);
495
502
  }
496
503
  isExcluded(symbol) {
497
504
  this.excludeCache ??= new MinimatchSet(this.application.options.getValue("exclude"));
@@ -499,10 +506,10 @@ let Converter = (() => {
499
506
  return (symbol.getDeclarations() ?? []).some((node) => cache.matchesAny(node.getSourceFile().fileName));
500
507
  }
501
508
  /** @internal */
502
- isExternal(symbol) {
509
+ isExternal(symbol, checker) {
503
510
  this.externalPatternCache ??= new MinimatchSet(this.externalPattern);
504
511
  const cache = this.externalPatternCache;
505
- const declarations = symbol.getDeclarations();
512
+ const declarations = resolveAliasedSymbol(symbol, checker).getDeclarations();
506
513
  // `undefined` has no declarations, if someone does `export default undefined`
507
514
  // the symbol ends up as having no declarations (the export symbol does, but
508
515
  // not the source symbol)
@@ -246,3 +246,5 @@ regionTagREsByExt["php"] = regionTagREsByExt["cs"];
246
246
  regionTagREsByExt["ps1"] = regionTagREsByExt["cs"];
247
247
  regionTagREsByExt["py"] = regionTagREsByExt["cs"];
248
248
  regionTagREsByExt["js"] = regionTagREsByExt["ts"];
249
+ regionTagREsByExt["mts"] = regionTagREsByExt["ts"];
250
+ regionTagREsByExt["cts"] = regionTagREsByExt["ts"];
@@ -8,6 +8,7 @@ import { convertTypeParameters, createConstructSignatureWithType, createSignatur
8
8
  import { convertJsDocAlias, convertJsDocCallback } from "./jsdoc.js";
9
9
  import { getHeritageTypes } from "./utils/nodes.js";
10
10
  import { removeUndefined } from "./utils/reflections.js";
11
+ import { resolveAliasedSymbol } from "./utils/symbols.js";
11
12
  const symbolConverters = {
12
13
  [ts.SymbolFlags.RegularEnum]: convertEnum,
13
14
  [ts.SymbolFlags.ConstEnum]: convertEnum,
@@ -61,7 +62,7 @@ for (const key of Object.keys(symbolConverters)) {
61
62
  }
62
63
  assert(conversionOrder.reduce((a, b) => a | b, 0) === allConverterFlags, "conversionOrder contains a symbol flag that converters do not.");
63
64
  function _convertSymbolNow(context, symbol, exportSymbol) {
64
- if (context.shouldIgnore(symbol)) {
65
+ if (context.shouldIgnore(resolveAliasedSymbol(symbol, context.checker))) {
65
66
  return;
66
67
  }
67
68
  // This check can catch symbols which ought to be documented as references
@@ -795,5 +795,11 @@ function convertTypeInlined(context, type) {
795
795
  const elementType = convertType(context, context.checker.getTypeArguments(type)[0]);
796
796
  return new ArrayType(elementType);
797
797
  }
798
+ if (isTypeReference(type) && context.checker.isTupleType(type)) {
799
+ const tupleNode = context.checker.typeToTypeNode(type.target, void 0, ts.NodeBuilderFlags.IgnoreErrors);
800
+ if (ts.isTupleTypeNode(tupleNode)) {
801
+ return tupleConverter.convertType(context, type, tupleNode);
802
+ }
803
+ }
798
804
  return typeLiteralConverter.convertType(context, type);
799
805
  }
@@ -118,7 +118,6 @@ module.exports = {
118
118
  failed_to_resolve_0_to_ts_path: `Failed to resolve entry point path {0} from package.json to a TypeScript source file`,
119
119
  use_expand_or_glob_for_files_in_dir: `If you wanted to include files inside this directory, set --entryPointStrategy to expand or specify a glob`,
120
120
  glob_0_did_not_match_any_files: `The glob {0} did not match any files`,
121
- glob_should_use_posix_slash: `Try replacing Windows path separators (\\) with posix path separators (/)`,
122
121
  entry_point_0_did_not_match_any_files_after_exclude: `The glob {0} did not match any files after applying exclude patterns`,
123
122
  entry_point_0_did_not_exist: `Provided entry point {0} does not exist`,
124
123
  entry_point_0_did_not_match_any_packages: `The entry point glob {0} did not match any directories containing package.json`,
@@ -129,6 +128,7 @@ module.exports = {
129
128
  // options
130
129
  circular_reference_extends_0: `Circular reference encountered for "extends" field of {0}`,
131
130
  failed_resolve_0_to_file_in_1: `Failed to resolve {0} to a file in {1}`,
131
+ glob_0_should_use_posix_slash: `The glob "{0}" escapes a non-special character. Glob inputs to TypeDoc may not use Windows path separators (\\), try replacing with posix path separators (/)`,
132
132
  option_0_can_only_be_specified_by_config_file: `The '{0}' option can only be specified via a config file`,
133
133
  option_0_expected_a_value_but_none_provided: `--{0} expected a value, but none was given as an argument`,
134
134
  unknown_option_0_may_have_meant_1: `Unknown option: {0}, you may have meant:\n\t{1}`,
@@ -109,7 +109,6 @@ declare const _default: {
109
109
  readonly failed_to_resolve_0_to_ts_path: "Failed to resolve entry point path {0} from package.json to a TypeScript source file";
110
110
  readonly use_expand_or_glob_for_files_in_dir: "If you wanted to include files inside this directory, set --entryPointStrategy to expand or specify a glob";
111
111
  readonly glob_0_did_not_match_any_files: "The glob {0} did not match any files";
112
- readonly glob_should_use_posix_slash: "Try replacing Windows path separators (\\) with posix path separators (/)";
113
112
  readonly entry_point_0_did_not_match_any_files_after_exclude: "The glob {0} did not match any files after applying exclude patterns";
114
113
  readonly entry_point_0_did_not_exist: "Provided entry point {0} does not exist";
115
114
  readonly entry_point_0_did_not_match_any_packages: "The entry point glob {0} did not match any directories containing package.json";
@@ -118,6 +117,7 @@ declare const _default: {
118
117
  readonly saved_relative_path_0_resolved_from_1_is_not_a_file: "Serialized project referenced {0}, which does not exist relative to {1}";
119
118
  readonly circular_reference_extends_0: "Circular reference encountered for \"extends\" field of {0}";
120
119
  readonly failed_resolve_0_to_file_in_1: "Failed to resolve {0} to a file in {1}";
120
+ readonly glob_0_should_use_posix_slash: "The glob \"{0}\" escapes a non-special character. Glob inputs to TypeDoc may not use Windows path separators (\\), try replacing with posix path separators (/)";
121
121
  readonly option_0_can_only_be_specified_by_config_file: "The '{0}' option can only be specified via a config file";
122
122
  readonly option_0_expected_a_value_but_none_provided: "--{0} expected a value, but none was given as an argument";
123
123
  readonly unknown_option_0_may_have_meant_1: "Unknown option: {0}, you may have meant:\n\t{1}";
@@ -89,7 +89,6 @@ module.exports = localeUtils.buildIncompleteTranslation({
89
89
  entry_point_0_not_in_program: "エントリ ポイント {0} は、tsconfig の 'files' または 'include' オプションによって参照されていません。",
90
90
  use_expand_or_glob_for_files_in_dir: "このディレクトリ内のファイルを含める場合は、--entryPointStrategyを設定して展開するか、globを指定します。",
91
91
  glob_0_did_not_match_any_files: "グロブ {0} はどのファイルにも一致しませんでした",
92
- // glob_should_use_posix_slash
93
92
  entry_point_0_did_not_match_any_files_after_exclude: "除外パターンを適用した後、グロブ {0} はどのファイルにも一致しませんでした",
94
93
  entry_point_0_did_not_exist: "指定されたエントリ ポイント {0} は存在しません",
95
94
  entry_point_0_did_not_match_any_packages: "エントリ ポイント glob {0} は、package.json を含むディレクトリと一致しませんでした。",
@@ -120,7 +120,6 @@ module.exports = localeUtils.buildIncompleteTranslation({
120
120
  failed_to_resolve_0_to_ts_path: "无法将 package.json 中的入口点 {0} 解析至 TypeScript 源文件",
121
121
  use_expand_or_glob_for_files_in_dir: "如果要包含此目录中的文件,请设置 --entryPointStrategy 以展开或指定 glob",
122
122
  glob_0_did_not_match_any_files: "glob {0} 与任何文件均不匹配",
123
- glob_should_use_posix_slash: `请将 Windows 路径分隔符(\\)替换为 POSIX 路径分隔符(/)`,
124
123
  entry_point_0_did_not_match_any_files_after_exclude: "应用排除模式后,glob {0} 没有匹配任何文件",
125
124
  entry_point_0_did_not_exist: "提供的入口点 {0} 不存在",
126
125
  entry_point_0_did_not_match_any_packages: "入口点 glob {0} 与任何包含 package.json 的目录不匹配",
@@ -109,7 +109,6 @@ declare const _default: {
109
109
  failed_to_resolve_0_to_ts_path: "无法将 package.json 中的入口点 {0} 解析至 TypeScript 源文件";
110
110
  use_expand_or_glob_for_files_in_dir: string;
111
111
  glob_0_did_not_match_any_files: "glob {0} 与任何文件均不匹配";
112
- glob_should_use_posix_slash: string;
113
112
  entry_point_0_did_not_match_any_files_after_exclude: "应用排除模式后,glob {0} 没有匹配任何文件";
114
113
  entry_point_0_did_not_exist: "提供的入口点 {0} 不存在";
115
114
  entry_point_0_did_not_match_any_packages: "入口点 glob {0} 与任何包含 package.json 的目录不匹配";
@@ -1,7 +1,41 @@
1
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
2
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
4
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
5
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6
+ var _, done = false;
7
+ for (var i = decorators.length - 1; i >= 0; i--) {
8
+ var context = {};
9
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
10
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
11
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
12
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13
+ if (kind === "accessor") {
14
+ if (result === void 0) continue;
15
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
16
+ if (_ = accept(result.get)) descriptor.get = _;
17
+ if (_ = accept(result.set)) descriptor.set = _;
18
+ if (_ = accept(result.init)) initializers.unshift(_);
19
+ }
20
+ else if (_ = accept(result)) {
21
+ if (kind === "field") initializers.unshift(_);
22
+ else descriptor[key] = _;
23
+ }
24
+ }
25
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
26
+ done = true;
27
+ };
28
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
29
+ var useValue = arguments.length > 2;
30
+ for (var i = 0; i < initializers.length; i++) {
31
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
32
+ }
33
+ return useValue ? value : void 0;
34
+ };
1
35
  import { ReflectionSymbolId } from "./ReflectionSymbolId.js";
2
36
  import { ReflectionKind } from "./kind.js";
3
37
  import { Comment } from "./Comment.js";
4
- import { i18n, joinArray } from "#utils";
38
+ import { i18n, joinArray, NonEnumerable } from "#utils";
5
39
  /**
6
40
  * Base class of all type definitions.
7
41
  * @category Types
@@ -658,227 +692,241 @@ export class QueryType extends Type {
658
692
  * ```
659
693
  * @category Types
660
694
  */
661
- export class ReferenceType extends Type {
662
- type = "reference";
663
- /**
664
- * The name of the referenced type.
665
- *
666
- * If the symbol cannot be found because it's not part of the documentation this
667
- * can be used to represent the type.
668
- */
669
- name;
670
- /**
671
- * The type arguments of this reference.
672
- */
673
- typeArguments;
674
- /**
675
- * The resolved reflection.
676
- */
677
- get reflection() {
678
- if (typeof this._target === "number") {
679
- return this._project?.getReflectionById(this._target);
680
- }
681
- const resolvePotential = this._project?.getReflectionsFromSymbolId(this._target);
682
- if (!resolvePotential?.length) {
683
- return;
684
- }
685
- const kind = this.preferValues
686
- ? ReflectionKind.ValueReferenceTarget
687
- : ReflectionKind.TypeReferenceTarget;
688
- const resolved = resolvePotential.find((refl) => refl.kindOf(kind)) ||
689
- resolvePotential.find((refl) => refl.kindOf(~kind));
690
- // Do not mark the type as resolved at this point so that if it
691
- // points to a member which is removed (e.g. by typedoc-plugin-zod)
692
- // and then replaced it still ends up pointing at the right reflection.
693
- // We will lock type reference resolution when serializing to JSON.
694
- // this._target = resolved.id;
695
- return resolved;
696
- }
697
- /**
698
- * Sometimes a few properties are more important than the rest
699
- * of the properties within a type. This occurs most often with
700
- * object parameters, where users want to specify `@param foo.bar`
701
- * to highlight something about the `bar` property.
702
- *
703
- * Does NOT support nested properties.
704
- */
705
- highlightedProperties;
706
- /**
707
- * If not resolved, the symbol id of the reflection, otherwise undefined.
708
- */
709
- get symbolId() {
710
- if (!this.reflection && typeof this._target === "object") {
711
- return this._target;
712
- }
713
- }
714
- /**
715
- * Checks if this type is a reference type because it uses a name, but is intentionally not pointing
716
- * to a reflection. This happens for type parameters and when representing a mapped type.
717
- */
718
- isIntentionallyBroken() {
719
- if (typeof this._target === "object" &&
720
- this._project?.symbolIdHasBeenRemoved(this._target)) {
721
- return true;
695
+ let ReferenceType = (() => {
696
+ let _classSuper = Type;
697
+ let __project_decorators;
698
+ let __project_initializers = [];
699
+ let __project_extraInitializers = [];
700
+ return class ReferenceType extends _classSuper {
701
+ static {
702
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
703
+ __project_decorators = [NonEnumerable];
704
+ __esDecorate(null, null, __project_decorators, { kind: "field", name: "_project", static: false, private: false, access: { has: obj => "_project" in obj, get: obj => obj._project, set: (obj, value) => { obj._project = value; } }, metadata: _metadata }, __project_initializers, __project_extraInitializers);
705
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
722
706
  }
723
- return this._target === -1 || this.refersToTypeParameter;
724
- }
725
- /**
726
- * Convert this reference type to a declaration reference used for resolution of external types.
727
- */
728
- toDeclarationReference() {
729
- return {
730
- resolutionStart: "global",
731
- moduleSource: this.package,
732
- symbolReference: {
733
- path: this.qualifiedName
734
- .split(".")
735
- .map((p) => ({ path: p, navigation: "." })),
736
- },
737
- };
738
- }
739
- /**
740
- * The fully qualified name of the referenced type, relative to the file it is defined in.
741
- * This will usually be the same as `name`, unless namespaces are used.
742
- */
743
- qualifiedName;
744
- /**
745
- * The package that this type is referencing.
746
- */
747
- package;
748
- /**
749
- * If this reference type refers to a reflection defined by a project not being rendered,
750
- * points to the url that this type should be linked to.
751
- */
752
- externalUrl;
753
- /**
754
- * If set, no warnings about something not being exported should be created
755
- * since this may be referring to a type created with `infer X` which will not
756
- * be registered on the project.
757
- */
758
- refersToTypeParameter = false;
759
- /**
760
- * If set, will prefer reflections with {@link ReflectionKind | ReflectionKinds} which represent
761
- * values rather than those which represent types.
762
- */
763
- preferValues = false;
764
- _target;
765
- _project;
766
- constructor(name, target, project, qualifiedName) {
767
- super();
768
- this.name = name;
769
- if (typeof target === "number") {
770
- this._target = target;
707
+ type = "reference";
708
+ /**
709
+ * The name of the referenced type.
710
+ *
711
+ * If the symbol cannot be found because it's not part of the documentation this
712
+ * can be used to represent the type.
713
+ */
714
+ name;
715
+ /**
716
+ * The type arguments of this reference.
717
+ */
718
+ typeArguments;
719
+ /**
720
+ * The resolved reflection.
721
+ */
722
+ get reflection() {
723
+ if (typeof this._target === "number") {
724
+ return this._project?.getReflectionById(this._target);
725
+ }
726
+ const resolvePotential = this._project?.getReflectionsFromSymbolId(this._target);
727
+ if (!resolvePotential?.length) {
728
+ return;
729
+ }
730
+ const kind = this.preferValues
731
+ ? ReflectionKind.ValueReferenceTarget
732
+ : ReflectionKind.TypeReferenceTarget;
733
+ const resolved = resolvePotential.find((refl) => refl.kindOf(kind)) ||
734
+ resolvePotential.find((refl) => refl.kindOf(~kind));
735
+ // Do not mark the type as resolved at this point so that if it
736
+ // points to a member which is removed (e.g. by typedoc-plugin-zod)
737
+ // and then replaced it still ends up pointing at the right reflection.
738
+ // We will lock type reference resolution when serializing to JSON.
739
+ // this._target = resolved.id;
740
+ return resolved;
771
741
  }
772
- else {
773
- this._target = "variant" in target ? target.id : target;
742
+ /**
743
+ * Sometimes a few properties are more important than the rest
744
+ * of the properties within a type. This occurs most often with
745
+ * object parameters, where users want to specify `@param foo.bar`
746
+ * to highlight something about the `bar` property.
747
+ *
748
+ * Does NOT support nested properties.
749
+ */
750
+ highlightedProperties;
751
+ /**
752
+ * If not resolved, the symbol id of the reflection, otherwise undefined.
753
+ */
754
+ get symbolId() {
755
+ if (!this.reflection && typeof this._target === "object") {
756
+ return this._target;
757
+ }
774
758
  }
775
- this._project = project;
776
- this.qualifiedName = qualifiedName;
777
- }
778
- static createUnresolvedReference(name, target, project, qualifiedName) {
779
- return new ReferenceType(name, target, project, qualifiedName);
780
- }
781
- static createResolvedReference(name, target, project) {
782
- return new ReferenceType(name, target, project, name);
783
- }
784
- /**
785
- * This is used for type parameters, which don't actually point to something,
786
- * and also for temporary references which will be cleaned up with real references
787
- * later during conversion.
788
- * @internal
789
- */
790
- static createBrokenReference(name, project) {
791
- return new ReferenceType(name, -1, project, name);
792
- }
793
- getTypeString() {
794
- const name = this.reflection ? this.reflection.name : this.name;
795
- let typeArgs = "";
796
- if (this.typeArguments && this.typeArguments.length > 0) {
797
- typeArgs += "<";
798
- typeArgs += this.typeArguments
799
- .map((arg) => arg.stringify(TypeContext.referenceTypeArgument))
800
- .join(", ");
801
- typeArgs += ">";
759
+ /**
760
+ * Checks if this type is a reference type because it uses a name, but is intentionally not pointing
761
+ * to a reflection. This happens for type parameters and when representing a mapped type.
762
+ */
763
+ isIntentionallyBroken() {
764
+ if (typeof this._target === "object" &&
765
+ this._project?.symbolIdHasBeenRemoved(this._target)) {
766
+ return true;
767
+ }
768
+ return this._target === -1 || this.refersToTypeParameter;
802
769
  }
803
- return name + typeArgs;
804
- }
805
- needsParenthesis() {
806
- return false;
807
- }
808
- toObject(serializer) {
809
- let target;
810
- if (typeof this._target === "number") {
811
- target = this._target;
770
+ /**
771
+ * Convert this reference type to a declaration reference used for resolution of external types.
772
+ */
773
+ toDeclarationReference() {
774
+ return {
775
+ resolutionStart: "global",
776
+ moduleSource: this.package,
777
+ symbolReference: {
778
+ path: this.qualifiedName
779
+ .split(".")
780
+ .map((p) => ({ path: p, navigation: "." })),
781
+ },
782
+ };
812
783
  }
813
- else if (this._project?.symbolIdHasBeenRemoved(this._target)) {
814
- target = -1;
784
+ /**
785
+ * The fully qualified name of the referenced type, relative to the file it is defined in.
786
+ * This will usually be the same as `name`, unless namespaces are used.
787
+ */
788
+ qualifiedName;
789
+ /**
790
+ * The package that this type is referencing.
791
+ */
792
+ package;
793
+ /**
794
+ * If this reference type refers to a reflection defined by a project not being rendered,
795
+ * points to the url that this type should be linked to.
796
+ */
797
+ externalUrl;
798
+ /**
799
+ * If set, no warnings about something not being exported should be created
800
+ * since this may be referring to a type created with `infer X` which will not
801
+ * be registered on the project.
802
+ */
803
+ refersToTypeParameter = false;
804
+ /**
805
+ * If set, will prefer reflections with {@link ReflectionKind | ReflectionKinds} which represent
806
+ * values rather than those which represent types.
807
+ */
808
+ preferValues = false;
809
+ _target;
810
+ _project = __runInitializers(this, __project_initializers, void 0);
811
+ constructor(name, target, project, qualifiedName) {
812
+ super();
813
+ __runInitializers(this, __project_extraInitializers);
814
+ this.name = name;
815
+ if (typeof target === "number") {
816
+ this._target = target;
817
+ }
818
+ else {
819
+ this._target = "variant" in target ? target.id : target;
820
+ }
821
+ this._project = project;
822
+ this.qualifiedName = qualifiedName;
815
823
  }
816
- else if (this.reflection) {
817
- target = this.reflection.id;
824
+ static createUnresolvedReference(name, target, project, qualifiedName) {
825
+ return new ReferenceType(name, target, project, qualifiedName);
818
826
  }
819
- else {
820
- target = this._target.toObject();
827
+ static createResolvedReference(name, target, project) {
828
+ return new ReferenceType(name, target, project, name);
821
829
  }
822
- const result = {
823
- type: this.type,
824
- target,
825
- typeArguments: serializer.toObjectsOptional(this.typeArguments),
826
- name: this.name,
827
- package: this.package,
828
- externalUrl: this.externalUrl,
829
- };
830
- if (this.name !== this.qualifiedName) {
831
- result.qualifiedName = this.qualifiedName;
830
+ /**
831
+ * This is used for type parameters, which don't actually point to something,
832
+ * and also for temporary references which will be cleaned up with real references
833
+ * later during conversion.
834
+ * @internal
835
+ */
836
+ static createBrokenReference(name, project) {
837
+ return new ReferenceType(name, -1, project, name);
832
838
  }
833
- if (this.refersToTypeParameter) {
834
- result.refersToTypeParameter = true;
839
+ getTypeString() {
840
+ const name = this.reflection ? this.reflection.name : this.name;
841
+ let typeArgs = "";
842
+ if (this.typeArguments && this.typeArguments.length > 0) {
843
+ typeArgs += "<";
844
+ typeArgs += this.typeArguments
845
+ .map((arg) => arg.stringify(TypeContext.referenceTypeArgument))
846
+ .join(", ");
847
+ typeArgs += ">";
848
+ }
849
+ return name + typeArgs;
835
850
  }
836
- if (typeof target !== "number" && this.preferValues) {
837
- result.preferValues = true;
851
+ needsParenthesis() {
852
+ return false;
838
853
  }
839
- if (this.highlightedProperties) {
840
- result.highlightedProperties = Object.fromEntries(Array.from(this.highlightedProperties.entries(), ([key, parts]) => {
841
- return [
842
- key,
843
- Comment.serializeDisplayParts(parts),
844
- ];
845
- }));
854
+ toObject(serializer) {
855
+ let target;
856
+ if (typeof this._target === "number") {
857
+ target = this._target;
858
+ }
859
+ else if (this._project?.symbolIdHasBeenRemoved(this._target)) {
860
+ target = -1;
861
+ }
862
+ else if (this.reflection) {
863
+ target = this.reflection.id;
864
+ }
865
+ else {
866
+ target = this._target.toObject();
867
+ }
868
+ const result = {
869
+ type: this.type,
870
+ target,
871
+ typeArguments: serializer.toObjectsOptional(this.typeArguments),
872
+ name: this.name,
873
+ package: this.package,
874
+ externalUrl: this.externalUrl,
875
+ };
876
+ if (this.name !== this.qualifiedName) {
877
+ result.qualifiedName = this.qualifiedName;
878
+ }
879
+ if (this.refersToTypeParameter) {
880
+ result.refersToTypeParameter = true;
881
+ }
882
+ if (typeof target !== "number" && this.preferValues) {
883
+ result.preferValues = true;
884
+ }
885
+ if (this.highlightedProperties) {
886
+ result.highlightedProperties = Object.fromEntries(Array.from(this.highlightedProperties.entries(), ([key, parts]) => {
887
+ return [
888
+ key,
889
+ Comment.serializeDisplayParts(parts),
890
+ ];
891
+ }));
892
+ }
893
+ return result;
846
894
  }
847
- return result;
848
- }
849
- fromObject(de, obj) {
850
- this.typeArguments = de.reviveMany(obj.typeArguments, (t) => de.constructType(t));
851
- if (typeof obj.target === "number" && obj.target !== -1) {
852
- de.defer((project) => {
853
- const target = project.getReflectionById(de.oldIdToNewId[obj.target] ?? -1);
854
- if (target) {
855
- this._project = project;
856
- this._target = target.id;
857
- }
858
- else {
859
- de.logger.warn(i18n.serialized_project_referenced_0_not_part_of_project(JSON.stringify(obj.target)));
895
+ fromObject(de, obj) {
896
+ this.typeArguments = de.reviveMany(obj.typeArguments, (t) => de.constructType(t));
897
+ if (typeof obj.target === "number" && obj.target !== -1) {
898
+ de.defer((project) => {
899
+ const target = project.getReflectionById(de.oldIdToNewId[obj.target] ?? -1);
900
+ if (target) {
901
+ this._project = project;
902
+ this._target = target.id;
903
+ }
904
+ else {
905
+ de.logger.warn(i18n.serialized_project_referenced_0_not_part_of_project(JSON.stringify(obj.target)));
906
+ }
907
+ });
908
+ }
909
+ else if (obj.target === -1) {
910
+ this._target = -1;
911
+ }
912
+ else {
913
+ this._project = de.project;
914
+ this._target = new ReflectionSymbolId(obj.target);
915
+ }
916
+ this.qualifiedName = obj.qualifiedName ?? obj.name;
917
+ this.package = obj.package;
918
+ this.refersToTypeParameter = !!obj.refersToTypeParameter;
919
+ this.preferValues = !!obj.preferValues;
920
+ if (obj.highlightedProperties) {
921
+ this.highlightedProperties = new Map();
922
+ for (const [key, parts] of Object.entries(obj.highlightedProperties)) {
923
+ this.highlightedProperties.set(key, Comment.deserializeDisplayParts(de, parts));
860
924
  }
861
- });
862
- }
863
- else if (obj.target === -1) {
864
- this._target = -1;
865
- }
866
- else {
867
- this._project = de.project;
868
- this._target = new ReflectionSymbolId(obj.target);
869
- }
870
- this.qualifiedName = obj.qualifiedName ?? obj.name;
871
- this.package = obj.package;
872
- this.refersToTypeParameter = !!obj.refersToTypeParameter;
873
- this.preferValues = !!obj.preferValues;
874
- if (obj.highlightedProperties) {
875
- this.highlightedProperties = new Map();
876
- for (const [key, parts] of Object.entries(obj.highlightedProperties)) {
877
- this.highlightedProperties.set(key, Comment.deserializeDisplayParts(de, parts));
878
925
  }
879
926
  }
880
- }
881
- }
927
+ };
928
+ })();
929
+ export { ReferenceType };
882
930
  /**
883
931
  * Represents a type which has it's own reflection like literal types.
884
932
  * This type will likely go away at some point and be replaced by a dedicated
@@ -204,6 +204,11 @@ let MarkedPlugin = (() => {
204
204
  .reflection_0_links_to_1_with_text_2_but_resolved_to_3(page.model.getFriendlyFullName(), part.target.getFriendlyFullName(), part.text, target.getFriendlyFullName()));
205
205
  }
206
206
  }
207
+ // If the url goes to this page, render as `#`
208
+ // to go to the top of the page.
209
+ if (url == "") {
210
+ url = "#";
211
+ }
207
212
  }
208
213
  if (useHtml) {
209
214
  const text = part.tag === "@linkcode" ? `<code>${part.text}</code>` : part.text;
@@ -231,9 +231,6 @@ function expandGlobs(globs, exclude, logger) {
231
231
  // #2918 - do not pass entry through nicePath here in case it contains
232
232
  // windows path separators which should cause additional warnings.
233
233
  logger.warn(i18n.glob_0_did_not_match_any_files(entry));
234
- if (entry.includes("\\") && !entry.includes("/")) {
235
- logger.info(i18n.glob_should_use_posix_slash());
236
- }
237
234
  }
238
235
  else if (filtered.length === 0) {
239
236
  logger.warn(i18n.entry_point_0_did_not_match_any_files_after_exclude(entry));
@@ -1,7 +1,8 @@
1
1
  import * as shiki from "@gerrit0/mini-shiki";
2
2
  import { JSX, unique } from "#utils";
3
3
  import assert from "assert";
4
- const aliases = new Map();
4
+ const tsAliases = [["mts", "typescript"], ["cts", "typescript"]];
5
+ const aliases = new Map(tsAliases);
5
6
  for (const lang of shiki.bundledLanguagesInfo) {
6
7
  for (const alias of lang.aliases || []) {
7
8
  aliases.set(alias, lang.id);
@@ -131,7 +132,7 @@ export function getSupportedThemes() {
131
132
  return supportedThemes;
132
133
  }
133
134
  export function isLoadedLanguage(lang) {
134
- return (plaintextLanguages.includes(lang) || ignoredLanguages?.includes(lang) || highlighter?.supports(lang) || false);
135
+ return (isSupportedLanguage(lang) || highlighter?.supports(lang) || false);
135
136
  }
136
137
  export function highlight(code, lang) {
137
138
  assert(highlighter, "Tried to highlight with an uninitialized highlighter");
@@ -199,7 +199,17 @@ const converters = {
199
199
  return resolved;
200
200
  },
201
201
  [ParameterType.GlobArray](value, option, configPath) {
202
- const toGlobString = (v) => createGlobString(configPath, String(v));
202
+ const toGlobString = (v) => {
203
+ const s = String(v);
204
+ // If the string tries to escape a character which isn't a special
205
+ // glob character, the user probably provided a Windows style path
206
+ // by accident due to shell completion, tell them to either remove
207
+ // the useless escape or switch to Unix path separators.
208
+ if (/\\[^?*()[\]\\{}]/.test(s)) {
209
+ throw new Error(i18n.glob_0_should_use_posix_slash(s));
210
+ }
211
+ return createGlobString(configPath, s);
212
+ };
203
213
  const globs = Array.isArray(value) ? value.map(toGlobString) : [toGlobString(value)];
204
214
  option.validate?.(globs);
205
215
  return globs;
@@ -8,6 +8,8 @@ export declare class ArgumentsReader implements OptionsReader {
8
8
  readonly order: number;
9
9
  readonly supportsPackages = false;
10
10
  private args;
11
+ private skipErrorReporting;
11
12
  constructor(priority: number, args?: string[]);
13
+ ignoreErrors(): this;
12
14
  read(container: Options, logger: Logger): void;
13
15
  }
@@ -15,10 +15,15 @@ export class ArgumentsReader {
15
15
  order;
16
16
  supportsPackages = false;
17
17
  args;
18
+ skipErrorReporting = false;
18
19
  constructor(priority, args = process.argv.slice(2)) {
19
20
  this.order = priority;
20
21
  this.args = args;
21
22
  }
23
+ ignoreErrors() {
24
+ this.skipErrorReporting = true;
25
+ return this;
26
+ }
22
27
  read(container, logger) {
23
28
  // Make container's type more lax, we do the appropriate checks manually.
24
29
  const options = container;
@@ -30,7 +35,9 @@ export class ArgumentsReader {
30
35
  }
31
36
  catch (err) {
32
37
  ok(err instanceof Error);
33
- logger.error(err.message);
38
+ if (!this.skipErrorReporting) {
39
+ logger.error(err.message);
40
+ }
34
41
  }
35
42
  };
36
43
  while (index < this.args.length) {
@@ -40,7 +47,9 @@ export class ArgumentsReader {
40
47
  : options.getDeclaration("entryPoints");
41
48
  if (decl) {
42
49
  if (decl.configFileOnly) {
43
- logger.error(i18n.option_0_can_only_be_specified_by_config_file(decl.name));
50
+ if (!this.skipErrorReporting) {
51
+ logger.error(i18n.option_0_can_only_be_specified_by_config_file(decl.name));
52
+ }
44
53
  continue;
45
54
  }
46
55
  if (seen.has(decl.name) && ARRAY_OPTION_TYPES.has(decl.type)) {
@@ -61,7 +70,9 @@ export class ArgumentsReader {
61
70
  else {
62
71
  if (index === this.args.length) {
63
72
  // Only boolean values have optional values.
64
- logger.warn(i18n.option_0_expected_a_value_but_none_provided(decl.name));
73
+ if (!this.skipErrorReporting) {
74
+ logger.warn(i18n.option_0_expected_a_value_but_none_provided(decl.name));
75
+ }
65
76
  }
66
77
  trySet(decl.name, this.args[index]);
67
78
  }
@@ -87,7 +98,9 @@ export class ArgumentsReader {
87
98
  continue;
88
99
  }
89
100
  }
90
- logger.error(i18n.unknown_option_0_may_have_meant_1(name, options.getSimilarOptions(name).join("\n\t")));
101
+ if (!this.skipErrorReporting) {
102
+ logger.error(i18n.unknown_option_0_may_have_meant_1(name, options.getSimilarOptions(name).join("\n\t")));
103
+ }
91
104
  index++;
92
105
  }
93
106
  }
@@ -2,6 +2,7 @@ export declare const emptyArray: readonly [];
2
2
  /**
3
3
  * Inserts an item into an array sorted by priority. If two items have the same priority,
4
4
  * the item will be inserted later will be placed later in the array.
5
+ * Higher priority is placed earlier in the array.
5
6
  * @param arr modified by inserting item.
6
7
  * @param item
7
8
  */
@@ -2,6 +2,7 @@ export const emptyArray = [];
2
2
  /**
3
3
  * Inserts an item into an array sorted by priority. If two items have the same priority,
4
4
  * the item will be inserted later will be placed later in the array.
5
+ * Higher priority is placed earlier in the array.
5
6
  * @param arr modified by inserting item.
6
7
  * @param item
7
8
  */
@@ -11,6 +11,7 @@ export declare class EventDispatcher<T extends Record<keyof T, unknown[]>> {
11
11
  * @param event the event to listen to.
12
12
  * @param listener function to be called when an this event is emitted.
13
13
  * @param priority optional priority to insert this hook with.
14
+ * Higher priority is placed earlier in the listener array.
14
15
  */
15
16
  on<K extends keyof T>(event: K, listener: (this: undefined, ...args: T[K]) => void, priority?: number): void;
16
17
  /**
@@ -14,6 +14,7 @@ export class EventDispatcher {
14
14
  * @param event the event to listen to.
15
15
  * @param listener function to be called when an this event is emitted.
16
16
  * @param priority optional priority to insert this hook with.
17
+ * Higher priority is placed earlier in the listener array.
17
18
  */
18
19
  on(event, listener, priority = 0) {
19
20
  const list = (this._listeners.get(event) || []).slice();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typedoc",
3
3
  "description": "Create api documentation for TypeScript projects.",
4
- "version": "0.28.2",
4
+ "version": "0.28.3",
5
5
  "homepage": "https://typedoc.org",
6
6
  "type": "module",
7
7
  "exports": {