typedoc 0.25.1 → 0.25.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.
Files changed (30) hide show
  1. package/dist/lib/application.js +10 -3
  2. package/dist/lib/converter/comments/discovery.js +8 -2
  3. package/dist/lib/converter/comments/index.js +9 -1
  4. package/dist/lib/converter/factories/index-signature.js +1 -0
  5. package/dist/lib/converter/factories/signature.d.ts +1 -0
  6. package/dist/lib/converter/factories/signature.js +28 -1
  7. package/dist/lib/converter/jsdoc.js +2 -6
  8. package/dist/lib/converter/plugins/CommentPlugin.js +1 -1
  9. package/dist/lib/converter/plugins/GroupPlugin.d.ts +1 -0
  10. package/dist/lib/converter/plugins/GroupPlugin.js +13 -2
  11. package/dist/lib/converter/symbols.js +4 -1
  12. package/dist/lib/converter/types.js +15 -13
  13. package/dist/lib/models/reflections/ReflectionSymbolId.d.ts +1 -0
  14. package/dist/lib/models/reflections/ReflectionSymbolId.js +16 -9
  15. package/dist/lib/models/reflections/abstract.js +257 -200
  16. package/dist/lib/output/themes/MarkedPlugin.js +16 -9
  17. package/dist/lib/output/themes/default/DefaultTheme.js +4 -0
  18. package/dist/lib/output/themes/default/partials/footer.js +1 -1
  19. package/dist/lib/output/themes/default/partials/icon.js +6 -0
  20. package/dist/lib/output/themes/default/partials/member.sources.js +25 -11
  21. package/dist/lib/utils/entry-point.js +12 -7
  22. package/dist/lib/utils/general.d.ts +1 -0
  23. package/dist/lib/utils/general.js +11 -1
  24. package/dist/lib/utils/jsx.js +4 -3
  25. package/dist/lib/utils/options/declaration.d.ts +3 -0
  26. package/dist/lib/utils/options/sources/typedoc.js +31 -15
  27. package/dist/lib/utils/sort.d.ts +1 -1
  28. package/dist/lib/utils/sort.js +4 -0
  29. package/package.json +9 -9
  30. package/static/main.js +1 -1
@@ -96,6 +96,7 @@ const application_events_1 = require("./application-events");
96
96
  const tsconfig_1 = require("./utils/tsconfig");
97
97
  const fs_1 = require("./utils/fs");
98
98
  const abstract_1 = require("./models/reflections/abstract");
99
+ const ReflectionSymbolId_1 = require("./models/reflections/ReflectionSymbolId");
99
100
  // eslint-disable-next-line @typescript-eslint/no-var-requires
100
101
  const packageInfo = require("../../package.json");
101
102
  const supportedVersionMajorMinor = packageInfo.peerDependencies.typescript
@@ -451,19 +452,25 @@ let Application = (() => {
451
452
  }
452
453
  const origOptions = this.options;
453
454
  const projects = [];
455
+ const projectsToConvert = [];
454
456
  // Generate a json file for each package
455
457
  for (const dir of packageDirs) {
456
- this.logger.info(`Converting project at ${(0, paths_1.nicePath)(dir)}`);
458
+ this.logger.verbose(`Reading project at ${(0, paths_1.nicePath)(dir)}`);
457
459
  const opts = origOptions.copyForPackage(dir);
460
+ await opts.read(this.logger, dir);
458
461
  // Invalid links should only be reported after everything has been merged.
459
462
  opts.setValue("validation", { invalidLink: false });
460
- await opts.read(this.logger, dir);
461
463
  if (opts.getValue("entryPointStrategy") ===
462
464
  entry_point_1.EntryPointStrategy.Packages) {
463
465
  this.logger.error(`Project at ${(0, paths_1.nicePath)(dir)} has entryPointStrategy set to packages, but nested packages are not supported.`);
464
466
  continue;
465
467
  }
466
- this.options = opts;
468
+ (0, ReflectionSymbolId_1.addInferredDeclarationMapPaths)(opts.getCompilerOptions(), opts.getFileNames());
469
+ projectsToConvert.push({ dir, options: opts });
470
+ }
471
+ for (const { dir, options } of projectsToConvert) {
472
+ this.logger.info(`Converting project at ${(0, paths_1.nicePath)(dir)}`);
473
+ this.options = options;
467
474
  const project = await this.convert();
468
475
  if (project) {
469
476
  this.validate(project);
@@ -28,8 +28,14 @@ const variablePropertyKinds = [
28
28
  // the JSDoc converter because we only want part of the comment when
29
29
  // getting them.
30
30
  const wantedKinds = {
31
- [models_1.ReflectionKind.Project]: [typescript_1.default.SyntaxKind.SourceFile],
32
- [models_1.ReflectionKind.Module]: [typescript_1.default.SyntaxKind.SourceFile],
31
+ [models_1.ReflectionKind.Project]: [
32
+ typescript_1.default.SyntaxKind.SourceFile,
33
+ typescript_1.default.SyntaxKind.ModuleDeclaration,
34
+ ],
35
+ [models_1.ReflectionKind.Module]: [
36
+ typescript_1.default.SyntaxKind.SourceFile,
37
+ typescript_1.default.SyntaxKind.ModuleDeclaration,
38
+ ],
33
39
  [models_1.ReflectionKind.Namespace]: [
34
40
  typescript_1.default.SyntaxKind.ModuleDeclaration,
35
41
  typescript_1.default.SyntaxKind.SourceFile,
@@ -74,7 +74,15 @@ function getComment(symbol, kind, config, logger, commentStyle, checker) {
74
74
  declarations.every((d) => jsDocCommentKinds.includes(d.kind))) {
75
75
  return getJsDocComment(declarations[0], config, logger, checker);
76
76
  }
77
- const comment = getCommentImpl((0, discovery_1.discoverComment)(symbol, kind, logger, commentStyle), config, logger, declarations.some(typescript_1.default.isSourceFile), checker);
77
+ const isModule = declarations.some((decl) => {
78
+ if (typescript_1.default.isSourceFile(decl))
79
+ return true;
80
+ if (typescript_1.default.isModuleDeclaration(decl) && typescript_1.default.isStringLiteral(decl.name)) {
81
+ return true;
82
+ }
83
+ return false;
84
+ });
85
+ const comment = getCommentImpl((0, discovery_1.discoverComment)(symbol, kind, logger, commentStyle), config, logger, isModule, checker);
78
86
  if (!comment && kind === models_1.ReflectionKind.Property) {
79
87
  return getConstructorParamPropertyComment(symbol, config, logger, commentStyle, checker);
80
88
  }
@@ -21,6 +21,7 @@ function convertIndexSignature(context, symbol) {
21
21
  const param = indexDeclaration.parameters[0];
22
22
  (0, assert_1.default)(param && typescript_1.default.isParameter(param));
23
23
  const index = new models_1.SignatureReflection("__index", models_1.ReflectionKind.IndexSignature, context.scope);
24
+ index.comment = context.getComment(indexSymbol, index.kind);
24
25
  index.parameters = [
25
26
  new models_1.ParameterReflection(param.name.getText(), models_1.ReflectionKind.Parameter, index),
26
27
  ];
@@ -5,3 +5,4 @@ export declare function createSignature(context: Context, kind: ReflectionKind.C
5
5
  export declare function convertParameterNodes(context: Context, sigRef: SignatureReflection, parameters: readonly (ts.JSDocParameterTag | ts.ParameterDeclaration)[]): ParameterReflection[];
6
6
  export declare function convertTypeParameterNodes(context: Context, parameters: readonly ts.TypeParameterDeclaration[] | undefined): TypeParameterReflection[] | undefined;
7
7
  export declare function createTypeParamReflection(param: ts.TypeParameterDeclaration, context: Context): TypeParameterReflection;
8
+ export declare function convertTemplateParameterNodes(context: Context, nodes: readonly ts.JSDocTemplateTag[] | undefined): TypeParameterReflection[] | undefined;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createTypeParamReflection = exports.convertTypeParameterNodes = exports.convertParameterNodes = exports.createSignature = void 0;
6
+ exports.convertTemplateParameterNodes = exports.createTypeParamReflection = exports.convertTypeParameterNodes = exports.convertParameterNodes = exports.createSignature = void 0;
7
7
  const typescript_1 = __importDefault(require("typescript"));
8
8
  const assert_1 = __importDefault(require("assert"));
9
9
  const models_1 = require("../../models");
@@ -195,6 +195,33 @@ function createTypeParamReflection(param, context) {
195
195
  return paramRefl;
196
196
  }
197
197
  exports.createTypeParamReflection = createTypeParamReflection;
198
+ function convertTemplateParameterNodes(context, nodes) {
199
+ return nodes?.flatMap((node) => {
200
+ return node.typeParameters.map((param, index) => {
201
+ const paramRefl = new models_1.TypeParameterReflection(param.name.text, context.scope, getVariance(param.modifiers));
202
+ const paramScope = context.withScope(paramRefl);
203
+ paramRefl.type =
204
+ index || !node.constraint
205
+ ? void 0
206
+ : context.converter.convertType(paramScope, node.constraint.type);
207
+ paramRefl.default = param.default
208
+ ? context.converter.convertType(paramScope, param.default)
209
+ : void 0;
210
+ if (param.modifiers?.some((m) => m.kind === typescript_1.default.SyntaxKind.ConstKeyword)) {
211
+ paramRefl.flags.setFlag(models_1.ReflectionFlag.Const, true);
212
+ }
213
+ context.registerReflection(paramRefl, param.symbol);
214
+ if (typescript_1.default.isJSDocTemplateTag(param.parent)) {
215
+ paramRefl.comment = context.getJsDocComment(param.parent);
216
+ }
217
+ context.trigger(converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER, paramRefl, param);
218
+ return paramRefl;
219
+ });
220
+ });
221
+ const params = (nodes ?? []).flatMap((tag) => tag.typeParameters);
222
+ return convertTypeParameterNodes(context, params);
223
+ }
224
+ exports.convertTemplateParameterNodes = convertTemplateParameterNodes;
198
225
  function getVariance(modifiers) {
199
226
  const hasIn = modifiers?.some((mod) => mod.kind === typescript_1.default.SyntaxKind.InKeyword);
200
227
  const hasOut = modifiers?.some((mod) => mod.kind === typescript_1.default.SyntaxKind.OutKeyword);
@@ -70,16 +70,12 @@ function convertJsDocSignature(context, node) {
70
70
  reflection.signatures = [signature];
71
71
  signature.type = context.converter.convertType(signatureCtx, node.type?.typeExpression?.type);
72
72
  signature.parameters = (0, signature_1.convertParameterNodes)(signatureCtx, signature, node.parameters);
73
- signature.typeParameters = convertTemplateParameterNodes(context.withScope(reflection), node.typeParameters);
73
+ signature.typeParameters = (0, signature_1.convertTemplateParameterNodes)(context.withScope(reflection), node.typeParameters);
74
74
  return new models_1.ReflectionType(reflection);
75
75
  }
76
76
  function convertTemplateParameters(context, node) {
77
77
  (0, assert_1.ok)(context.scope instanceof models_1.DeclarationReflection);
78
- context.scope.typeParameters = convertTemplateParameterNodes(context, node.tags?.filter(typescript_1.default.isJSDocTemplateTag));
79
- }
80
- function convertTemplateParameterNodes(context, nodes) {
81
- const params = (nodes ?? []).flatMap((tag) => tag.typeParameters);
82
- return (0, signature_1.convertTypeParameterNodes)(context, params);
78
+ context.scope.typeParameters = (0, signature_1.convertTemplateParameterNodes)(context, node.tags?.filter(typescript_1.default.isJSDocTemplateTag));
83
79
  }
84
80
  function getTypedefReExportTarget(context, declaration) {
85
81
  const typeExpression = declaration.typeExpression;
@@ -291,7 +291,7 @@ let CommentPlugin = (() => {
291
291
  const comment = reflection.comment;
292
292
  if (!comment)
293
293
  return;
294
- if (reflection.kindOf(models_1.ReflectionKind.Module)) {
294
+ if (reflection.kindOf(models_1.ReflectionKind.SomeModule)) {
295
295
  const tag = comment.getTag("@module");
296
296
  if (tag) {
297
297
  // If no name is specified, this is a flag to mark a comment as a module comment
@@ -10,6 +10,7 @@ export declare class GroupPlugin extends ConverterComponent {
10
10
  sortFunction: (reflections: DeclarationReflection[]) => void;
11
11
  accessor boosts: Record<string, number>;
12
12
  accessor groupOrder: string[];
13
+ accessor sortEntryPoints: boolean;
13
14
  usedBoosts: Set<string>;
14
15
  static WEIGHTS: string[];
15
16
  /**
@@ -63,7 +63,7 @@ const models_1 = require("../../models");
63
63
  * The handler sets the `groups` property of all container reflections.
64
64
  */
65
65
  let GroupPlugin = (() => {
66
- var _GroupPlugin_boosts_accessor_storage, _GroupPlugin_groupOrder_accessor_storage;
66
+ var _GroupPlugin_boosts_accessor_storage, _GroupPlugin_groupOrder_accessor_storage, _GroupPlugin_sortEntryPoints_accessor_storage;
67
67
  let _classDecorators = [(0, components_1.Component)({ name: "group" })];
68
68
  let _classDescriptor;
69
69
  let _classExtraInitializers = [];
@@ -74,18 +74,23 @@ let GroupPlugin = (() => {
74
74
  let _boosts_initializers = [];
75
75
  let _groupOrder_decorators;
76
76
  let _groupOrder_initializers = [];
77
+ let _sortEntryPoints_decorators;
78
+ let _sortEntryPoints_initializers = [];
77
79
  var GroupPlugin = _classThis = class extends _classSuper {
78
80
  constructor() {
79
81
  super(...arguments);
80
82
  this.sortFunction = (__runInitializers(this, _instanceExtraInitializers), void 0);
81
83
  _GroupPlugin_boosts_accessor_storage.set(this, __runInitializers(this, _boosts_initializers, void 0));
82
84
  _GroupPlugin_groupOrder_accessor_storage.set(this, __runInitializers(this, _groupOrder_initializers, void 0));
85
+ _GroupPlugin_sortEntryPoints_accessor_storage.set(this, __runInitializers(this, _sortEntryPoints_initializers, void 0));
83
86
  this.usedBoosts = new Set();
84
87
  }
85
88
  get boosts() { return __classPrivateFieldGet(this, _GroupPlugin_boosts_accessor_storage, "f"); }
86
89
  set boosts(value) { __classPrivateFieldSet(this, _GroupPlugin_boosts_accessor_storage, value, "f"); }
87
90
  get groupOrder() { return __classPrivateFieldGet(this, _GroupPlugin_groupOrder_accessor_storage, "f"); }
88
91
  set groupOrder(value) { __classPrivateFieldSet(this, _GroupPlugin_groupOrder_accessor_storage, value, "f"); }
92
+ get sortEntryPoints() { return __classPrivateFieldGet(this, _GroupPlugin_sortEntryPoints_accessor_storage, "f"); }
93
+ set sortEntryPoints(value) { __classPrivateFieldSet(this, _GroupPlugin_sortEntryPoints_accessor_storage, value, "f"); }
89
94
  /**
90
95
  * Create a new GroupPlugin instance.
91
96
  */
@@ -132,7 +137,10 @@ let GroupPlugin = (() => {
132
137
  if (reflection.children &&
133
138
  reflection.children.length > 0 &&
134
139
  !reflection.groups) {
135
- this.sortFunction(reflection.children);
140
+ if (this.sortEntryPoints ||
141
+ !reflection.children.some((c) => c.kindOf(index_1.ReflectionKind.Module))) {
142
+ this.sortFunction(reflection.children);
143
+ }
136
144
  reflection.groups = this.getReflectionGroups(reflection.children);
137
145
  }
138
146
  }
@@ -226,13 +234,16 @@ let GroupPlugin = (() => {
226
234
  };
227
235
  _GroupPlugin_boosts_accessor_storage = new WeakMap();
228
236
  _GroupPlugin_groupOrder_accessor_storage = new WeakMap();
237
+ _GroupPlugin_sortEntryPoints_accessor_storage = new WeakMap();
229
238
  __setFunctionName(_classThis, "GroupPlugin");
230
239
  (() => {
231
240
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
232
241
  _boosts_decorators = [(0, utils_1.Option)("searchGroupBoosts")];
233
242
  _groupOrder_decorators = [(0, utils_1.Option)("groupOrder")];
243
+ _sortEntryPoints_decorators = [(0, utils_1.Option)("sortEntryPoints")];
234
244
  __esDecorate(_classThis, null, _boosts_decorators, { kind: "accessor", name: "boosts", static: false, private: false, access: { has: obj => "boosts" in obj, get: obj => obj.boosts, set: (obj, value) => { obj.boosts = value; } }, metadata: _metadata }, _boosts_initializers, _instanceExtraInitializers);
235
245
  __esDecorate(_classThis, null, _groupOrder_decorators, { kind: "accessor", name: "groupOrder", static: false, private: false, access: { has: obj => "groupOrder" in obj, get: obj => obj.groupOrder, set: (obj, value) => { obj.groupOrder = value; } }, metadata: _metadata }, _groupOrder_initializers, _instanceExtraInitializers);
246
+ __esDecorate(_classThis, null, _sortEntryPoints_decorators, { kind: "accessor", name: "sortEntryPoints", static: false, private: false, access: { has: obj => "sortEntryPoints" in obj, get: obj => obj.sortEntryPoints, set: (obj, value) => { obj.sortEntryPoints = value; } }, metadata: _metadata }, _sortEntryPoints_initializers, _instanceExtraInitializers);
236
247
  __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
237
248
  GroupPlugin = _classThis = _classDescriptor.value;
238
249
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
@@ -572,7 +572,10 @@ function convertAccessor(context, symbol, exportSymbol) {
572
572
  }
573
573
  function isInherited(context, symbol) {
574
574
  const parentSymbol = context.project.getSymbolFromReflection(context.scope);
575
- (0, assert_1.default)(parentSymbol, `No parent symbol found for ${symbol.name} in ${context.scope.name}`);
575
+ // It'd be nice to be able to assert that this is true, but sometimes object
576
+ // types don't get symbols if they are inferred.
577
+ if (!parentSymbol)
578
+ return false;
576
579
  const parents = parentSymbol.declarations?.slice() || [];
577
580
  const constructorDecls = parents.flatMap((parent) => typescript_1.default.isClassDeclaration(parent)
578
581
  ? parent.members.filter(typescript_1.default.isConstructorDeclaration)
@@ -164,13 +164,14 @@ const constructorConverter = {
164
164
  return new models_1.ReflectionType(reflection);
165
165
  },
166
166
  convertType(context, type) {
167
- if (!type.symbol) {
167
+ const symbol = type.getSymbol();
168
+ if (!symbol) {
168
169
  return new models_1.IntrinsicType("Function");
169
170
  }
170
171
  const reflection = new models_1.DeclarationReflection("__type", models_1.ReflectionKind.Constructor, context.scope);
171
- context.registerReflection(reflection, type.symbol);
172
+ context.registerReflection(reflection, symbol);
172
173
  context.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, reflection);
173
- (0, signature_1.createSignature)(context.withScope(reflection), models_1.ReflectionKind.ConstructorSignature, type.getConstructSignatures()[0], type.symbol);
174
+ (0, signature_1.createSignature)(context.withScope(reflection), models_1.ReflectionKind.ConstructorSignature, type.getConstructSignatures()[0], symbol);
174
175
  return new models_1.ReflectionType(reflection);
175
176
  },
176
177
  };
@@ -212,11 +213,12 @@ const functionTypeConverter = {
212
213
  return new models_1.ReflectionType(reflection);
213
214
  },
214
215
  convertType(context, type) {
215
- if (!type.symbol) {
216
+ const symbol = type.getSymbol();
217
+ if (!symbol) {
216
218
  return new models_1.IntrinsicType("Function");
217
219
  }
218
220
  const reflection = new models_1.DeclarationReflection("__type", models_1.ReflectionKind.TypeLiteral, context.scope);
219
- context.registerReflection(reflection, type.symbol);
221
+ context.registerReflection(reflection, symbol);
220
222
  context.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, reflection);
221
223
  (0, signature_1.createSignature)(context.withScope(reflection), models_1.ReflectionKind.CallSignature, type.getCallSignatures()[0], type.getSymbol());
222
224
  return new models_1.ReflectionType(reflection);
@@ -251,7 +253,7 @@ const inferredConverter = {
251
253
  return new models_1.InferredType(node.typeParameter.name.text, maybeConvertType(context, node.typeParameter.constraint));
252
254
  },
253
255
  convertType(context, type) {
254
- return new models_1.InferredType(type.symbol.name, maybeConvertType(context, type.getConstraint()));
256
+ return new models_1.InferredType(type.getSymbol().name, maybeConvertType(context, type.getConstraint()));
255
257
  },
256
258
  };
257
259
  const intersectionConverter = {
@@ -372,22 +374,22 @@ const typeLiteralConverter = {
372
374
  return new models_1.ReflectionType(reflection);
373
375
  },
374
376
  convertType(context, type) {
375
- if (!type.symbol) {
376
- return new models_1.IntrinsicType("Object");
377
- }
377
+ const symbol = type.getSymbol();
378
378
  const reflection = new models_1.DeclarationReflection("__type", models_1.ReflectionKind.TypeLiteral, context.scope);
379
- context.registerReflection(reflection, type.symbol);
379
+ context.registerReflection(reflection, symbol);
380
380
  context.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, reflection);
381
381
  for (const prop of context.checker.getPropertiesOfType(type)) {
382
382
  (0, symbols_1.convertSymbol)(context.withScope(reflection), prop);
383
383
  }
384
384
  for (const signature of type.getCallSignatures()) {
385
- (0, signature_1.createSignature)(context.withScope(reflection), models_1.ReflectionKind.CallSignature, signature, type.symbol);
385
+ (0, signature_1.createSignature)(context.withScope(reflection), models_1.ReflectionKind.CallSignature, signature, symbol);
386
386
  }
387
387
  for (const signature of type.getConstructSignatures()) {
388
- (0, signature_1.createSignature)(context.withScope(reflection), models_1.ReflectionKind.ConstructorSignature, signature, type.symbol);
388
+ (0, signature_1.createSignature)(context.withScope(reflection), models_1.ReflectionKind.ConstructorSignature, signature, symbol);
389
+ }
390
+ if (symbol) {
391
+ (0, index_signature_1.convertIndexSignature)(context.withScope(reflection), symbol);
389
392
  }
390
- (0, index_signature_1.convertIndexSignature)(context.withScope(reflection), type.symbol);
391
393
  return new models_1.ReflectionType(reflection);
392
394
  },
393
395
  };
@@ -27,3 +27,4 @@ export declare class ReflectionSymbolId {
27
27
  qualifiedName: string;
28
28
  };
29
29
  }
30
+ export declare function addInferredDeclarationMapPaths(opts: ts.CompilerOptions, files: readonly string[]): void;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ReflectionSymbolId = void 0;
6
+ exports.addInferredDeclarationMapPaths = exports.ReflectionSymbolId = void 0;
7
7
  const fs_1 = require("fs");
8
8
  const path_1 = require("path");
9
9
  const typescript_1 = __importDefault(require("typescript"));
@@ -20,7 +20,7 @@ class ReflectionSymbolId {
20
20
  constructor(symbol, declaration) {
21
21
  if ("name" in symbol) {
22
22
  declaration ??= symbol?.declarations?.[0];
23
- this.fileName = (0, paths_1.normalizePath)(declaration?.getSourceFile().fileName ?? "\0");
23
+ this.fileName = (0, paths_1.normalizePath)(declaration?.getSourceFile().fileName ?? "");
24
24
  if (symbol.declarations?.some(typescript_1.default.isSourceFile)) {
25
25
  this.qualifiedName = "";
26
26
  }
@@ -44,21 +44,19 @@ class ReflectionSymbolId {
44
44
  }
45
45
  }
46
46
  toObject(serializer) {
47
+ const sourceFileName = (0, path_1.isAbsolute)(this.fileName)
48
+ ? (0, paths_1.normalizePath)((0, path_1.relative)(serializer.projectRoot, resolveDeclarationMaps(this.fileName)))
49
+ : this.fileName;
47
50
  return {
48
- sourceFileName: (0, path_1.isAbsolute)(this.fileName)
49
- ? (0, paths_1.normalizePath)((0, path_1.relative)(serializer.projectRoot, resolveDeclarationMaps(this.fileName)))
50
- : this.fileName,
51
+ sourceFileName,
51
52
  qualifiedName: this.qualifiedName,
52
53
  };
53
54
  }
54
55
  }
55
56
  exports.ReflectionSymbolId = ReflectionSymbolId;
56
57
  const declarationMapCache = new Map();
57
- /**
58
- * See also getTsSourceFromJsSource in package-manifest.ts.
59
- */
60
58
  function resolveDeclarationMaps(file) {
61
- if (!file.endsWith(".d.ts"))
59
+ if (!/\.d\.[cm]?ts$/.test(file))
62
60
  return file;
63
61
  if (declarationMapCache.has(file))
64
62
  return declarationMapCache.get(file);
@@ -93,3 +91,12 @@ function resolveDeclarationMaps(file) {
93
91
  }
94
92
  return file;
95
93
  }
94
+ function addInferredDeclarationMapPaths(opts, files) {
95
+ const rootDir = opts.rootDir || (0, fs_2.getCommonDirectory)(files);
96
+ const declDir = opts.declarationDir || opts.outDir || rootDir;
97
+ for (const file of files) {
98
+ const mapFile = (0, path_1.resolve)(declDir, (0, path_1.relative)(rootDir, file)).replace(/\.([cm]?[tj]s)x?$/, ".d.$1");
99
+ declarationMapCache.set(mapFile, file);
100
+ }
101
+ }
102
+ exports.addInferredDeclarationMapPaths = addInferredDeclarationMapPaths;