typedoc 0.26.1 → 0.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,12 +6,9 @@ export interface DiscoveredComment {
6
6
  file: ts.SourceFile;
7
7
  ranges: ts.CommentRange[];
8
8
  jsDoc: ts.JSDoc | undefined;
9
+ inheritedFromParentDeclaration: boolean;
9
10
  }
10
- export declare function discoverFileComments(node: ts.SourceFile, commentStyle: CommentStyle): {
11
- file: ts.SourceFile;
12
- ranges: ts.CommentRange[];
13
- jsDoc: ts.JSDoc | undefined;
14
- }[];
11
+ export declare function discoverFileComments(node: ts.SourceFile, commentStyle: CommentStyle): DiscoveredComment[];
15
12
  export declare function discoverNodeComment(node: ts.Node, commentStyle: CommentStyle): DiscoveredComment | undefined;
16
- export declare function discoverComment(symbol: ts.Symbol, kind: ReflectionKind, logger: Logger, commentStyle: CommentStyle): DiscoveredComment | undefined;
17
- export declare function discoverSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, commentStyle: CommentStyle): DiscoveredComment | undefined;
13
+ export declare function discoverComment(symbol: ts.Symbol, kind: ReflectionKind, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker): DiscoveredComment | undefined;
14
+ export declare function discoverSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, checker: ts.TypeChecker, commentStyle: CommentStyle): DiscoveredComment | undefined;
@@ -13,6 +13,7 @@ const utils_1 = require("../../utils");
13
13
  const declaration_1 = require("../../utils/options/declaration");
14
14
  const paths_1 = require("../../utils/paths");
15
15
  const assert_1 = require("assert");
16
+ const array_1 = require("../../utils/array");
16
17
  const variablePropertyKinds = [
17
18
  typescript_1.default.SyntaxKind.PropertyDeclaration,
18
19
  typescript_1.default.SyntaxKind.PropertySignature,
@@ -128,6 +129,7 @@ function discoverFileComments(node, commentStyle) {
128
129
  file: node,
129
130
  ranges,
130
131
  jsDoc: findJsDocForComment(node, ranges),
132
+ inheritedFromParentDeclaration: false,
131
133
  };
132
134
  });
133
135
  }
@@ -141,99 +143,119 @@ function discoverNodeComment(node, commentStyle) {
141
143
  file: node.getSourceFile(),
142
144
  ranges: selectedDocComment,
143
145
  jsDoc: findJsDocForComment(node, selectedDocComment),
146
+ inheritedFromParentDeclaration: false,
144
147
  };
145
148
  }
146
149
  }
147
- function discoverComment(symbol, kind, logger, commentStyle) {
150
+ function checkCommentDeclarations(commentNodes, reverse, commentStyle) {
151
+ const discovered = [];
152
+ for (const { node, inheritedFromParentDeclaration } of commentNodes) {
153
+ const text = node.getSourceFile().text;
154
+ const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
155
+ if (reverse) {
156
+ comments.reverse();
157
+ }
158
+ const selectedDocComment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
159
+ if (selectedDocComment) {
160
+ discovered.push({
161
+ file: node.getSourceFile(),
162
+ ranges: selectedDocComment,
163
+ jsDoc: findJsDocForComment(node, selectedDocComment),
164
+ inheritedFromParentDeclaration,
165
+ });
166
+ }
167
+ }
168
+ return discovered;
169
+ }
170
+ function discoverComment(symbol, kind, logger, commentStyle, checker) {
148
171
  // For a module comment, we want the first one defined in the file,
149
172
  // not the last one, since that will apply to the import or declaration.
150
173
  const reverse = !symbol.declarations?.some(typescript_1.default.isSourceFile);
151
- const discovered = [];
152
- const seen = new Set();
153
- for (const decl of symbol.declarations || []) {
154
- const text = decl.getSourceFile().text;
155
- if (wantedKinds[kind].includes(decl.kind)) {
156
- const node = declarationToCommentNode(decl);
157
- if (!node || seen.has(node)) {
158
- continue;
159
- }
160
- seen.add(node);
161
- // Special behavior here!
162
- // Signatures and symbols have two distinct discovery methods as of TypeDoc 0.26.
163
- // This method discovers comments for symbols, and function-likes will only have
164
- // a symbol comment if there is more than one signature (== more than one declaration)
165
- // and there is a comment on the implementation signature.
166
- if (kind & models_1.ReflectionKind.ContainsCallSignatures &&
167
- [
168
- typescript_1.default.SyntaxKind.FunctionDeclaration,
169
- typescript_1.default.SyntaxKind.MethodDeclaration,
170
- typescript_1.default.SyntaxKind.Constructor,
171
- ].includes(node.kind) &&
172
- (symbol.declarations.filter((d) => wantedKinds[kind].includes(d.kind)).length === 1 ||
173
- !node.body)) {
174
- continue;
175
- }
176
- const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
177
- if (reverse) {
178
- comments.reverse();
179
- }
180
- const selectedDocComment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
181
- if (selectedDocComment) {
182
- discovered.push({
183
- file: decl.getSourceFile(),
184
- ranges: selectedDocComment,
185
- jsDoc: findJsDocForComment(node, selectedDocComment),
174
+ const wantedDeclarations = (0, array_1.filter)(symbol.declarations, (decl) => wantedKinds[kind].includes(decl.kind));
175
+ const commentNodes = wantedDeclarations.flatMap((decl) => declarationToCommentNodes(decl, checker));
176
+ // Special behavior here!
177
+ // Signatures and symbols have two distinct discovery methods as of TypeDoc 0.26.
178
+ // This method discovers comments for symbols, and function-likes will only have
179
+ // a symbol comment if there is more than one signature (== more than one declaration)
180
+ // and there is a comment on the implementation signature.
181
+ if (kind & models_1.ReflectionKind.ContainsCallSignatures) {
182
+ const canHaveOverloads = wantedDeclarations.some((node) => [
183
+ typescript_1.default.SyntaxKind.FunctionDeclaration,
184
+ typescript_1.default.SyntaxKind.MethodDeclaration,
185
+ typescript_1.default.SyntaxKind.Constructor,
186
+ ].includes(node.kind));
187
+ const isOverloaded = canHaveOverloads && wantedDeclarations.length > 1;
188
+ if (isOverloaded) {
189
+ commentNodes.length = 0;
190
+ const implementationNode = wantedDeclarations.find((node) => node.body);
191
+ if (implementationNode) {
192
+ commentNodes.push({
193
+ node: implementationNode,
194
+ inheritedFromParentDeclaration: false,
186
195
  });
187
196
  }
188
197
  }
198
+ else if (canHaveOverloads) {
199
+ // Single signature function, function reflection doesn't get a comment,
200
+ // the signatures do.
201
+ commentNodes.length = 0;
202
+ }
203
+ else {
204
+ // Variable declaration which happens to include signatures.
205
+ }
189
206
  }
207
+ const discovered = checkCommentDeclarations(commentNodes, reverse, commentStyle);
190
208
  switch (discovered.length) {
191
209
  case 0:
192
210
  return undefined;
193
211
  case 1:
194
212
  return discovered[0];
195
213
  default: {
196
- logger.warn(logger.i18n.symbol_0_has_multiple_declarations_with_comment(symbol.name));
197
- const locations = discovered.map(({ file, ranges: [{ pos }] }) => {
198
- const path = (0, paths_1.nicePath)(file.fileName);
199
- const line = typescript_1.default.getLineAndCharacterOfPosition(file, pos).line + 1;
200
- return `${path}:${line}`;
201
- });
202
- logger.info(logger.i18n.comments_for_0_are_declared_at_1(symbol.name, locations.join("\n\t")));
214
+ if (discovered.filter((n) => !n.inheritedFromParentDeclaration)
215
+ .length > 1) {
216
+ logger.warn(logger.i18n.symbol_0_has_multiple_declarations_with_comment(symbol.name));
217
+ const locations = discovered.map(({ file, ranges: [{ pos }] }) => {
218
+ const path = (0, paths_1.nicePath)(file.fileName);
219
+ const line = typescript_1.default.getLineAndCharacterOfPosition(file, pos).line +
220
+ 1;
221
+ return `${path}:${line}`;
222
+ });
223
+ logger.info(logger.i18n.comments_for_0_are_declared_at_1(symbol.name, locations.join("\n\t")));
224
+ }
203
225
  return discovered[0];
204
226
  }
205
227
  }
206
228
  }
207
- function discoverSignatureComment(declaration, commentStyle) {
208
- const node = declarationToCommentNode(declaration);
209
- if (!node) {
210
- return;
211
- }
212
- if (typescript_1.default.isJSDocSignature(node)) {
213
- const comment = node.parent.parent;
214
- (0, assert_1.ok)(typescript_1.default.isJSDoc(comment));
215
- return {
216
- file: node.getSourceFile(),
217
- ranges: [
218
- {
219
- kind: typescript_1.default.SyntaxKind.MultiLineCommentTrivia,
220
- pos: comment.pos,
221
- end: comment.end,
222
- },
223
- ],
224
- jsDoc: comment,
225
- };
226
- }
227
- const text = node.getSourceFile().text;
228
- const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
229
- comments.reverse();
230
- const comment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
231
- if (comment) {
232
- return {
233
- file: node.getSourceFile(),
234
- ranges: comment,
235
- jsDoc: findJsDocForComment(node, comment),
236
- };
229
+ function discoverSignatureComment(declaration, checker, commentStyle) {
230
+ for (const { node, inheritedFromParentDeclaration, } of declarationToCommentNodes(declaration, checker)) {
231
+ if (typescript_1.default.isJSDocSignature(node)) {
232
+ const comment = node.parent.parent;
233
+ (0, assert_1.ok)(typescript_1.default.isJSDoc(comment));
234
+ return {
235
+ file: node.getSourceFile(),
236
+ ranges: [
237
+ {
238
+ kind: typescript_1.default.SyntaxKind.MultiLineCommentTrivia,
239
+ pos: comment.pos,
240
+ end: comment.end,
241
+ },
242
+ ],
243
+ jsDoc: comment,
244
+ inheritedFromParentDeclaration,
245
+ };
246
+ }
247
+ const text = node.getSourceFile().text;
248
+ const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
249
+ comments.reverse();
250
+ const comment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
251
+ if (comment) {
252
+ return {
253
+ file: node.getSourceFile(),
254
+ ranges: comment,
255
+ jsDoc: findJsDocForComment(node, comment),
256
+ inheritedFromParentDeclaration,
257
+ };
258
+ }
237
259
  }
238
260
  }
239
261
  function findJsDocForComment(node, ranges) {
@@ -282,7 +304,7 @@ function getRootModuleDeclaration(node) {
282
304
  }
283
305
  return node;
284
306
  }
285
- function declarationToCommentNode(node) {
307
+ function declarationToCommentNodeIgnoringParents(node) {
286
308
  // ts.SourceFile is a counterexample
287
309
  if (!node.parent)
288
310
  return node;
@@ -324,7 +346,54 @@ function declarationToCommentNode(node) {
324
346
  if (typescript_1.default.SyntaxKind.NamespaceExport === node.kind) {
325
347
  return node.parent;
326
348
  }
327
- return node;
349
+ }
350
+ function declarationToCommentNodes(node, checker) {
351
+ const commentNode = declarationToCommentNodeIgnoringParents(node);
352
+ if (commentNode) {
353
+ return [
354
+ {
355
+ node: commentNode,
356
+ inheritedFromParentDeclaration: false,
357
+ },
358
+ ];
359
+ }
360
+ const result = [
361
+ {
362
+ node,
363
+ inheritedFromParentDeclaration: false,
364
+ },
365
+ ];
366
+ const seenSymbols = new Set();
367
+ const bases = findBaseOfDeclaration(checker, node, (symbol) => {
368
+ if (!seenSymbols.has(symbol)) {
369
+ seenSymbols.add(symbol);
370
+ return symbol.declarations?.map((node) => declarationToCommentNodeIgnoringParents(node) || node);
371
+ }
372
+ });
373
+ for (const parentCommentNode of bases || []) {
374
+ result.push({
375
+ node: parentCommentNode,
376
+ inheritedFromParentDeclaration: true,
377
+ });
378
+ }
379
+ return result;
380
+ }
381
+ // Lifted from the TS source, with a couple minor modifications
382
+ function findBaseOfDeclaration(checker, declaration, cb) {
383
+ const classOrInterfaceDeclaration = declaration.parent?.kind === typescript_1.default.SyntaxKind.Constructor
384
+ ? declaration.parent.parent
385
+ : declaration.parent;
386
+ if (!classOrInterfaceDeclaration)
387
+ return;
388
+ const isStaticMember = typescript_1.default.getCombinedModifierFlags(declaration) & typescript_1.default.ModifierFlags.Static;
389
+ return (0, array_1.firstDefined)(typescript_1.default.getAllSuperTypeNodes(classOrInterfaceDeclaration), (superTypeNode) => {
390
+ const baseType = checker.getTypeAtLocation(superTypeNode);
391
+ const type = isStaticMember && baseType.symbol
392
+ ? checker.getTypeOfSymbol(baseType.symbol)
393
+ : baseType;
394
+ const symbol = checker.getPropertyOfType(type, declaration.symbol.name);
395
+ return symbol ? cb(symbol) : undefined;
396
+ });
328
397
  }
329
398
  /**
330
399
  * Separate comment ranges into arrays so that multiple line comments are kept together
@@ -8,10 +8,13 @@ export interface CommentParserConfig {
8
8
  inlineTags: Set<string>;
9
9
  modifierTags: Set<string>;
10
10
  jsDocCompatibility: JsDocCompatibility;
11
+ suppressCommentWarningsInDeclarationFiles: boolean;
12
+ useTsLinkResolution: boolean;
13
+ commentStyle: CommentStyle;
11
14
  }
12
15
  export declare function clearCommentCache(): void;
13
- export declare function getComment(symbol: ts.Symbol, kind: ReflectionKind, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
14
- export declare function getNodeComment(node: ts.Node, moduleComment: boolean, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
15
- export declare function getFileComment(file: ts.SourceFile, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
16
- export declare function getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
16
+ export declare function getComment(symbol: ts.Symbol, kind: ReflectionKind, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker, files: FileRegistry): Comment | undefined;
17
+ export declare function getNodeComment(node: ts.Node, moduleComment: boolean, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
18
+ export declare function getFileComment(file: ts.SourceFile, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
19
+ export declare function getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker, files: FileRegistry): Comment | undefined;
17
20
  export declare function getJsDocComment(declaration: ts.JSDocPropertyLikeTag | ts.JSDocCallbackTag | ts.JSDocTypedefTag | ts.JSDocTemplateTag | ts.JSDocEnumTag, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
@@ -38,7 +38,10 @@ function getCommentWithCache(discovered, config, logger, checker, files) {
38
38
  const { file, ranges, jsDoc } = discovered;
39
39
  const cache = commentCache.get(file) || new Map();
40
40
  if (cache.has(ranges[0].pos)) {
41
- return cache.get(ranges[0].pos).clone();
41
+ const clone = cache.get(ranges[0].pos).clone();
42
+ clone.inheritedFromParentDeclaration =
43
+ discovered.inheritedFromParentDeclaration;
44
+ return clone;
42
45
  }
43
46
  let comment;
44
47
  switch (ranges[0].kind) {
@@ -52,12 +55,14 @@ function getCommentWithCache(discovered, config, logger, checker, files) {
52
55
  (0, utils_1.assertNever)(ranges[0].kind);
53
56
  }
54
57
  comment.discoveryId = ++commentDiscoveryId;
58
+ comment.inheritedFromParentDeclaration =
59
+ discovered.inheritedFromParentDeclaration;
55
60
  cache.set(ranges[0].pos, comment);
56
61
  commentCache.set(file, cache);
57
62
  return comment.clone();
58
63
  }
59
64
  function getCommentImpl(commentSource, config, logger, moduleComment, checker, files) {
60
- const comment = getCommentWithCache(commentSource, config, logger, checker, files);
65
+ const comment = getCommentWithCache(commentSource, config, logger, config.useTsLinkResolution ? checker : undefined, files);
61
66
  if (comment?.getTag("@import") || comment?.getTag("@license")) {
62
67
  return;
63
68
  }
@@ -78,7 +83,7 @@ function getCommentImpl(commentSource, config, logger, moduleComment, checker, f
78
83
  }
79
84
  return comment;
80
85
  }
81
- function getComment(symbol, kind, config, logger, commentStyle, checker, files) {
86
+ function getComment(symbol, kind, config, logger, checker, files) {
82
87
  const declarations = symbol.declarations || [];
83
88
  if (declarations.length &&
84
89
  declarations.every((d) => jsDocCommentKinds.includes(d.kind))) {
@@ -86,7 +91,7 @@ function getComment(symbol, kind, config, logger, commentStyle, checker, files)
86
91
  }
87
92
  const sf = declarations.find(typescript_1.default.isSourceFile);
88
93
  if (sf) {
89
- return getFileComment(sf, config, logger, commentStyle, checker, files);
94
+ return getFileComment(sf, config, logger, checker, files);
90
95
  }
91
96
  const isModule = declarations.some((decl) => {
92
97
  if (typescript_1.default.isModuleDeclaration(decl) && typescript_1.default.isStringLiteral(decl.name)) {
@@ -94,18 +99,18 @@ function getComment(symbol, kind, config, logger, commentStyle, checker, files)
94
99
  }
95
100
  return false;
96
101
  });
97
- const comment = getCommentImpl((0, discovery_1.discoverComment)(symbol, kind, logger, commentStyle), config, logger, isModule, checker, files);
102
+ const comment = getCommentImpl((0, discovery_1.discoverComment)(symbol, kind, logger, config.commentStyle, checker), config, logger, isModule, checker, files);
98
103
  if (!comment && kind === models_1.ReflectionKind.Property) {
99
- return getConstructorParamPropertyComment(symbol, config, logger, commentStyle, checker, files);
104
+ return getConstructorParamPropertyComment(symbol, config, logger, checker, files);
100
105
  }
101
106
  return comment;
102
107
  }
103
- function getNodeComment(node, moduleComment, config, logger, commentStyle, checker, files) {
104
- return getCommentImpl((0, discovery_1.discoverNodeComment)(node, commentStyle), config, logger, moduleComment, checker, files);
108
+ function getNodeComment(node, moduleComment, config, logger, checker, files) {
109
+ return getCommentImpl((0, discovery_1.discoverNodeComment)(node, config.commentStyle), config, logger, moduleComment, checker, files);
105
110
  }
106
- function getFileComment(file, config, logger, commentStyle, checker, files) {
107
- for (const commentSource of (0, discovery_1.discoverFileComments)(file, commentStyle)) {
108
- const comment = getCommentWithCache(commentSource, config, logger, checker, files);
111
+ function getFileComment(file, config, logger, checker, files) {
112
+ for (const commentSource of (0, discovery_1.discoverFileComments)(file, config.commentStyle)) {
113
+ const comment = getCommentWithCache(commentSource, config, logger, config.useTsLinkResolution ? checker : undefined, files);
109
114
  if (comment?.getTag("@license") || comment?.getTag("@import")) {
110
115
  continue;
111
116
  }
@@ -116,12 +121,12 @@ function getFileComment(file, config, logger, commentStyle, checker, files) {
116
121
  return;
117
122
  }
118
123
  }
119
- function getConstructorParamPropertyComment(symbol, config, logger, commentStyle, checker, files) {
124
+ function getConstructorParamPropertyComment(symbol, config, logger, checker, files) {
120
125
  const decl = symbol.declarations?.find(typescript_1.default.isParameter);
121
126
  if (!decl)
122
127
  return;
123
128
  const ctor = decl.parent;
124
- const comment = getSignatureComment(ctor, config, logger, commentStyle, checker, files);
129
+ const comment = getSignatureComment(ctor, config, logger, checker, files);
125
130
  const paramTag = comment?.getIdentifiedTag(symbol.name, "@param");
126
131
  if (paramTag) {
127
132
  const result = new models_1.Comment(paramTag.content);
@@ -129,8 +134,8 @@ function getConstructorParamPropertyComment(symbol, config, logger, commentStyle
129
134
  return result;
130
135
  }
131
136
  }
132
- function getSignatureComment(declaration, config, logger, commentStyle, checker, files) {
133
- return getCommentImpl((0, discovery_1.discoverSignatureComment)(declaration, commentStyle), config, logger, false, checker, files);
137
+ function getSignatureComment(declaration, config, logger, checker, files) {
138
+ return getCommentImpl((0, discovery_1.discoverSignatureComment)(declaration, checker, config.commentStyle), config, logger, false, checker, files);
134
139
  }
135
140
  function getJsDocComment(declaration, config, logger, checker, files) {
136
141
  const file = declaration.getSourceFile();
@@ -150,7 +155,8 @@ function getJsDocComment(declaration, config, logger, checker, files) {
150
155
  },
151
156
  ],
152
157
  jsDoc: parent,
153
- }, config, logger, checker, files);
158
+ inheritedFromParentDeclaration: false,
159
+ }, config, logger, config.useTsLinkResolution ? checker : undefined, files);
154
160
  // And pull out the tag we actually care about.
155
161
  if (typescript_1.default.isJSDocEnumTag(declaration)) {
156
162
  const result = new models_1.Comment(comment.getTag("@enum")?.content);
@@ -79,6 +79,10 @@ function parseComment(tokens, config, file, logger, files) {
79
79
  postProcessComment(comment, logger.i18n, () => `${(0, paths_1.nicePath)(file.fileName)}:${file.getLineAndCharacterOfPosition(tok2.pos).line + 1}`, (message) => logger.warn(message));
80
80
  return comment;
81
81
  function warningImpl(message, token) {
82
+ if (config.suppressCommentWarningsInDeclarationFiles &&
83
+ file.fileName.endsWith(".d.ts")) {
84
+ return;
85
+ }
82
86
  logger.warn(message, token.pos, file);
83
87
  }
84
88
  }
@@ -98,6 +102,7 @@ function parseCommentString(tokens, config, file, logger, files) {
98
102
  ignoreUnescapedBraces: true,
99
103
  inheritDocTag: true,
100
104
  },
105
+ suppressCommentWarningsInDeclarationFiles: true,
101
106
  };
102
107
  const reentry = new textParser_1.TextParserReentryState();
103
108
  const content = [];
@@ -174,19 +174,19 @@ class Context {
174
174
  this._program = program;
175
175
  }
176
176
  getComment(symbol, kind) {
177
- return (0, comments_1.getComment)(symbol, kind, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
177
+ return (0, comments_1.getComment)(symbol, kind, this.converter.config, this.logger, this.checker, this.project.files);
178
178
  }
179
179
  getNodeComment(node, moduleComment) {
180
- return (0, comments_1.getNodeComment)(node, moduleComment, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
180
+ return (0, comments_1.getNodeComment)(node, moduleComment, this.converter.config, this.logger, this.checker, this.project.files);
181
181
  }
182
182
  getFileComment(node) {
183
- return (0, comments_1.getFileComment)(node, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
183
+ return (0, comments_1.getFileComment)(node, this.converter.config, this.logger, this.checker, this.project.files);
184
184
  }
185
185
  getJsDocComment(declaration) {
186
- return (0, comments_1.getJsDocComment)(declaration, this.converter.config, this.logger, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
186
+ return (0, comments_1.getJsDocComment)(declaration, this.converter.config, this.logger, this.checker, this.project.files);
187
187
  }
188
188
  getSignatureComment(declaration) {
189
- return (0, comments_1.getSignatureComment)(declaration, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
189
+ return (0, comments_1.getSignatureComment)(declaration, this.converter.config, this.logger, this.checker, this.project.files);
190
190
  }
191
191
  withScope(scope) {
192
192
  const context = new Context(this.converter, this.programs, this.project, scope);
@@ -56,8 +56,6 @@ export declare class Converter extends ChildableComponent<Application, Converter
56
56
  /** @internal */
57
57
  accessor externalSymbolLinkMappings: Record<string, Record<string, string>>;
58
58
  /** @internal */
59
- accessor useTsLinkResolution: boolean;
60
- /** @internal */
61
59
  accessor preserveLinkText: boolean;
62
60
  /** @internal */
63
61
  accessor maxTypeConversionDepth: number;
@@ -73,7 +73,7 @@ const path_1 = require("path");
73
73
  * Compiles source files using TypeScript and converts compiler symbols to reflections.
74
74
  */
75
75
  let Converter = (() => {
76
- var _Converter_externalPattern_accessor_storage, _Converter_excludeExternals_accessor_storage, _Converter_excludeNotDocumented_accessor_storage, _Converter_excludePrivate_accessor_storage, _Converter_excludeProtected_accessor_storage, _Converter_excludeReferences_accessor_storage, _Converter_commentStyle_accessor_storage, _Converter_validation_accessor_storage, _Converter_externalSymbolLinkMappings_accessor_storage, _Converter_useTsLinkResolution_accessor_storage, _Converter_preserveLinkText_accessor_storage, _Converter_maxTypeConversionDepth_accessor_storage;
76
+ var _Converter_externalPattern_accessor_storage, _Converter_excludeExternals_accessor_storage, _Converter_excludeNotDocumented_accessor_storage, _Converter_excludePrivate_accessor_storage, _Converter_excludeProtected_accessor_storage, _Converter_excludeReferences_accessor_storage, _Converter_commentStyle_accessor_storage, _Converter_validation_accessor_storage, _Converter_externalSymbolLinkMappings_accessor_storage, _Converter_preserveLinkText_accessor_storage, _Converter_maxTypeConversionDepth_accessor_storage;
77
77
  let _classDecorators = [(0, component_1.Component)({
78
78
  name: "converter",
79
79
  internal: true,
@@ -110,9 +110,6 @@ let Converter = (() => {
110
110
  let _externalSymbolLinkMappings_decorators;
111
111
  let _externalSymbolLinkMappings_initializers = [];
112
112
  let _externalSymbolLinkMappings_extraInitializers = [];
113
- let _useTsLinkResolution_decorators;
114
- let _useTsLinkResolution_initializers = [];
115
- let _useTsLinkResolution_extraInitializers = [];
116
113
  let _preserveLinkText_decorators;
117
114
  let _preserveLinkText_initializers = [];
118
115
  let _preserveLinkText_extraInitializers = [];
@@ -148,9 +145,6 @@ let Converter = (() => {
148
145
  get externalSymbolLinkMappings() { return __classPrivateFieldGet(this, _Converter_externalSymbolLinkMappings_accessor_storage, "f"); }
149
146
  set externalSymbolLinkMappings(value) { __classPrivateFieldSet(this, _Converter_externalSymbolLinkMappings_accessor_storage, value, "f"); }
150
147
  /** @internal */
151
- get useTsLinkResolution() { return __classPrivateFieldGet(this, _Converter_useTsLinkResolution_accessor_storage, "f"); }
152
- set useTsLinkResolution(value) { __classPrivateFieldSet(this, _Converter_useTsLinkResolution_accessor_storage, value, "f"); }
153
- /** @internal */
154
148
  get preserveLinkText() { return __classPrivateFieldGet(this, _Converter_preserveLinkText_accessor_storage, "f"); }
155
149
  set preserveLinkText(value) { __classPrivateFieldSet(this, _Converter_preserveLinkText_accessor_storage, value, "f"); }
156
150
  /** @internal */
@@ -171,8 +165,7 @@ let Converter = (() => {
171
165
  _Converter_commentStyle_accessor_storage.set(this, (__runInitializers(this, _excludeReferences_extraInitializers), __runInitializers(this, _commentStyle_initializers, void 0)));
172
166
  _Converter_validation_accessor_storage.set(this, (__runInitializers(this, _commentStyle_extraInitializers), __runInitializers(this, _validation_initializers, void 0)));
173
167
  _Converter_externalSymbolLinkMappings_accessor_storage.set(this, (__runInitializers(this, _validation_extraInitializers), __runInitializers(this, _externalSymbolLinkMappings_initializers, void 0)));
174
- _Converter_useTsLinkResolution_accessor_storage.set(this, (__runInitializers(this, _externalSymbolLinkMappings_extraInitializers), __runInitializers(this, _useTsLinkResolution_initializers, void 0)));
175
- _Converter_preserveLinkText_accessor_storage.set(this, (__runInitializers(this, _useTsLinkResolution_extraInitializers), __runInitializers(this, _preserveLinkText_initializers, void 0)));
168
+ _Converter_preserveLinkText_accessor_storage.set(this, (__runInitializers(this, _externalSymbolLinkMappings_extraInitializers), __runInitializers(this, _preserveLinkText_initializers, void 0)));
176
169
  _Converter_maxTypeConversionDepth_accessor_storage.set(this, (__runInitializers(this, _preserveLinkText_extraInitializers), __runInitializers(this, _maxTypeConversionDepth_initializers, void 0)));
177
170
  this._config = __runInitializers(this, _maxTypeConversionDepth_extraInitializers);
178
171
  this._externalSymbolResolvers = [];
@@ -468,6 +461,9 @@ let Converter = (() => {
468
461
  inlineTags: new Set(this.application.options.getValue("inlineTags")),
469
462
  modifierTags: new Set(this.application.options.getValue("modifierTags")),
470
463
  jsDocCompatibility: this.application.options.getValue("jsDocCompatibility"),
464
+ suppressCommentWarningsInDeclarationFiles: this.application.options.getValue("suppressCommentWarningsInDeclarationFiles"),
465
+ useTsLinkResolution: this.application.options.getValue("useTsLinkResolution"),
466
+ commentStyle: this.application.options.getValue("commentStyle"),
471
467
  };
472
468
  // Can't be included in options because the TSDoc parser blows up if we do.
473
469
  // TypeDoc supports it as one, so it should always be included here.
@@ -484,7 +480,6 @@ let Converter = (() => {
484
480
  _Converter_commentStyle_accessor_storage = new WeakMap();
485
481
  _Converter_validation_accessor_storage = new WeakMap();
486
482
  _Converter_externalSymbolLinkMappings_accessor_storage = new WeakMap();
487
- _Converter_useTsLinkResolution_accessor_storage = new WeakMap();
488
483
  _Converter_preserveLinkText_accessor_storage = new WeakMap();
489
484
  _Converter_maxTypeConversionDepth_accessor_storage = new WeakMap();
490
485
  __setFunctionName(_classThis, "Converter");
@@ -499,7 +494,6 @@ let Converter = (() => {
499
494
  _commentStyle_decorators = [(0, utils_1.Option)("commentStyle")];
500
495
  _validation_decorators = [(0, utils_1.Option)("validation")];
501
496
  _externalSymbolLinkMappings_decorators = [(0, utils_1.Option)("externalSymbolLinkMappings")];
502
- _useTsLinkResolution_decorators = [(0, utils_1.Option)("useTsLinkResolution")];
503
497
  _preserveLinkText_decorators = [(0, utils_1.Option)("preserveLinkText")];
504
498
  _maxTypeConversionDepth_decorators = [(0, utils_1.Option)("maxTypeConversionDepth")];
505
499
  __esDecorate(_classThis, null, _externalPattern_decorators, { kind: "accessor", name: "externalPattern", static: false, private: false, access: { has: obj => "externalPattern" in obj, get: obj => obj.externalPattern, set: (obj, value) => { obj.externalPattern = value; } }, metadata: _metadata }, _externalPattern_initializers, _externalPattern_extraInitializers);
@@ -511,7 +505,6 @@ let Converter = (() => {
511
505
  __esDecorate(_classThis, null, _commentStyle_decorators, { kind: "accessor", name: "commentStyle", static: false, private: false, access: { has: obj => "commentStyle" in obj, get: obj => obj.commentStyle, set: (obj, value) => { obj.commentStyle = value; } }, metadata: _metadata }, _commentStyle_initializers, _commentStyle_extraInitializers);
512
506
  __esDecorate(_classThis, null, _validation_decorators, { kind: "accessor", name: "validation", static: false, private: false, access: { has: obj => "validation" in obj, get: obj => obj.validation, set: (obj, value) => { obj.validation = value; } }, metadata: _metadata }, _validation_initializers, _validation_extraInitializers);
513
507
  __esDecorate(_classThis, null, _externalSymbolLinkMappings_decorators, { kind: "accessor", name: "externalSymbolLinkMappings", static: false, private: false, access: { has: obj => "externalSymbolLinkMappings" in obj, get: obj => obj.externalSymbolLinkMappings, set: (obj, value) => { obj.externalSymbolLinkMappings = value; } }, metadata: _metadata }, _externalSymbolLinkMappings_initializers, _externalSymbolLinkMappings_extraInitializers);
514
- __esDecorate(_classThis, null, _useTsLinkResolution_decorators, { kind: "accessor", name: "useTsLinkResolution", static: false, private: false, access: { has: obj => "useTsLinkResolution" in obj, get: obj => obj.useTsLinkResolution, set: (obj, value) => { obj.useTsLinkResolution = value; } }, metadata: _metadata }, _useTsLinkResolution_initializers, _useTsLinkResolution_extraInitializers);
515
508
  __esDecorate(_classThis, null, _preserveLinkText_decorators, { kind: "accessor", name: "preserveLinkText", static: false, private: false, access: { has: obj => "preserveLinkText" in obj, get: obj => obj.preserveLinkText, set: (obj, value) => { obj.preserveLinkText = value; } }, metadata: _metadata }, _preserveLinkText_initializers, _preserveLinkText_extraInitializers);
516
509
  __esDecorate(_classThis, null, _maxTypeConversionDepth_decorators, { kind: "accessor", name: "maxTypeConversionDepth", static: false, private: false, access: { has: obj => "maxTypeConversionDepth" in obj, get: obj => obj.maxTypeConversionDepth, set: (obj, value) => { obj.maxTypeConversionDepth = value; } }, metadata: _metadata }, _maxTypeConversionDepth_initializers, _maxTypeConversionDepth_extraInitializers);
517
510
  __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
@@ -596,7 +596,7 @@ let CommentPlugin = (() => {
596
596
  const paramTags = comment.blockTags.filter((tag) => tag.tag === "@param");
597
597
  (0, utils_1.removeIf)(paramTags, (tag) => params.some((param) => param.name === tag.name));
598
598
  moveNestedParamTags(/* in-out */ paramTags, params, comment.sourcePath);
599
- if (paramTags.length) {
599
+ if (!comment.inheritedFromParentDeclaration) {
600
600
  for (const tag of paramTags) {
601
601
  this.application.logger.warn(this.application.i18n.signature_0_has_unused_param_with_name_1(signature.getFriendlyFullName(), tag.name ?? "(missing)"));
602
602
  }
@@ -180,6 +180,13 @@ export declare class Comment {
180
180
  * @internal
181
181
  */
182
182
  discoveryId?: number;
183
+ /**
184
+ * If the comment was inherited from a different "parent" declaration
185
+ * (see #2545), then it is desirable to know this as any `@param` tags
186
+ * which do not apply should not cause warnings. This is not serialized,
187
+ * and only set when the comment was created from a `ts.CommentRange`.
188
+ */
189
+ inheritedFromParentDeclaration?: boolean;
183
190
  /**
184
191
  * Creates a new Comment instance.
185
192
  */
@@ -94,6 +94,9 @@ let Comment = (() => {
94
94
  let _discoveryId_decorators;
95
95
  let _discoveryId_initializers = [];
96
96
  let _discoveryId_extraInitializers = [];
97
+ let _inheritedFromParentDeclaration_decorators;
98
+ let _inheritedFromParentDeclaration_initializers = [];
99
+ let _inheritedFromParentDeclaration_extraInitializers = [];
97
100
  return _a = class Comment {
98
101
  /**
99
102
  * Debugging utility for combining parts into a simple string. Not suitable for
@@ -301,7 +304,14 @@ let Comment = (() => {
301
304
  * @internal
302
305
  */
303
306
  this.discoveryId = (__runInitializers(this, _sourcePath_extraInitializers), __runInitializers(this, _discoveryId_initializers, void 0));
304
- __runInitializers(this, _discoveryId_extraInitializers);
307
+ /**
308
+ * If the comment was inherited from a different "parent" declaration
309
+ * (see #2545), then it is desirable to know this as any `@param` tags
310
+ * which do not apply should not cause warnings. This is not serialized,
311
+ * and only set when the comment was created from a `ts.CommentRange`.
312
+ */
313
+ this.inheritedFromParentDeclaration = (__runInitializers(this, _discoveryId_extraInitializers), __runInitializers(this, _inheritedFromParentDeclaration_initializers, void 0));
314
+ __runInitializers(this, _inheritedFromParentDeclaration_extraInitializers);
305
315
  this.summary = summary;
306
316
  this.blockTags = blockTags;
307
317
  this.modifierTags = modifierTags;
@@ -314,6 +324,8 @@ let Comment = (() => {
314
324
  const comment = new _a(_a.cloneDisplayParts(this.summary), this.blockTags.map((tag) => tag.clone()), new Set(this.modifierTags));
315
325
  comment.discoveryId = this.discoveryId;
316
326
  comment.sourcePath = this.sourcePath;
327
+ comment.inheritedFromParentDeclaration =
328
+ this.inheritedFromParentDeclaration;
317
329
  return comment;
318
330
  }
319
331
  /**
@@ -395,8 +407,10 @@ let Comment = (() => {
395
407
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
396
408
  _sourcePath_decorators = [general_1.NonEnumerable];
397
409
  _discoveryId_decorators = [general_1.NonEnumerable];
410
+ _inheritedFromParentDeclaration_decorators = [general_1.NonEnumerable];
398
411
  __esDecorate(null, null, _sourcePath_decorators, { kind: "field", name: "sourcePath", static: false, private: false, access: { has: obj => "sourcePath" in obj, get: obj => obj.sourcePath, set: (obj, value) => { obj.sourcePath = value; } }, metadata: _metadata }, _sourcePath_initializers, _sourcePath_extraInitializers);
399
412
  __esDecorate(null, null, _discoveryId_decorators, { kind: "field", name: "discoveryId", static: false, private: false, access: { has: obj => "discoveryId" in obj, get: obj => obj.discoveryId, set: (obj, value) => { obj.discoveryId = value; } }, metadata: _metadata }, _discoveryId_initializers, _discoveryId_extraInitializers);
413
+ __esDecorate(null, null, _inheritedFromParentDeclaration_decorators, { kind: "field", name: "inheritedFromParentDeclaration", static: false, private: false, access: { has: obj => "inheritedFromParentDeclaration" in obj, get: obj => obj.inheritedFromParentDeclaration, set: (obj, value) => { obj.inheritedFromParentDeclaration = value; } }, metadata: _metadata }, _inheritedFromParentDeclaration_initializers, _inheritedFromParentDeclaration_extraInitializers);
400
414
  if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
401
415
  })(),
402
416
  _a;
@@ -1,3 +1,4 @@
1
+ export declare const emptyArray: readonly [];
1
2
  /**
2
3
  * Inserts an item into an array sorted by priority. If two items have the same priority,
3
4
  * the item will be inserted later will be placed earlier in the array.
@@ -48,3 +49,5 @@ export declare function zip<T extends Iterable<any>[]>(...args: T): Iterable<{
48
49
  [K in keyof T]: T[K] extends Iterable<infer U> ? U : T[K];
49
50
  }>;
50
51
  export declare function filterMap<T, U>(iter: Iterable<T>, fn: (item: T) => U | undefined): U[];
52
+ export declare function firstDefined<T, U>(array: readonly T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined;
53
+ export declare function filter<T>(array: readonly T[] | undefined, predicate: (value: T, index: number, array: readonly T[]) => boolean): readonly T[];
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emptyArray = void 0;
3
4
  exports.insertPrioritySorted = insertPrioritySorted;
4
5
  exports.insertOrderSorted = insertOrderSorted;
5
6
  exports.binaryFindPartition = binaryFindPartition;
@@ -9,6 +10,9 @@ exports.unique = unique;
9
10
  exports.partition = partition;
10
11
  exports.zip = zip;
11
12
  exports.filterMap = filterMap;
13
+ exports.firstDefined = firstDefined;
14
+ exports.filter = filter;
15
+ exports.emptyArray = [];
12
16
  /**
13
17
  * Inserts an item into an array sorted by priority. If two items have the same priority,
14
18
  * the item will be inserted later will be placed earlier in the array.
@@ -123,3 +127,18 @@ function filterMap(iter, fn) {
123
127
  }
124
128
  return result;
125
129
  }
130
+ function firstDefined(array, callback) {
131
+ if (array === undefined) {
132
+ return undefined;
133
+ }
134
+ for (let i = 0; i < array.length; i++) {
135
+ const result = callback(array[i], i);
136
+ if (result !== undefined) {
137
+ return result;
138
+ }
139
+ }
140
+ return undefined;
141
+ }
142
+ function filter(array, predicate) {
143
+ return array ? array.filter(predicate) : exports.emptyArray;
144
+ }
@@ -152,7 +152,7 @@ function getSupportedThemes() {
152
152
  return supportedThemes;
153
153
  }
154
154
  function isLoadedLanguage(lang) {
155
- return highlighter?.supports(lang) ?? false;
155
+ return lang === "text" || (highlighter?.supports(lang) ?? false);
156
156
  }
157
157
  function highlight(code, lang) {
158
158
  (0, assert_1.ok)(highlighter, "Tried to highlight with an uninitialized highlighter");
@@ -155,6 +155,7 @@ export interface TypeDocOptionMap {
155
155
  useTsLinkResolution: boolean;
156
156
  preserveLinkText: boolean;
157
157
  jsDocCompatibility: JsDocCompatibility;
158
+ suppressCommentWarningsInDeclarationFiles: boolean;
158
159
  blockTags: `@${string}`[];
159
160
  inlineTags: `@${string}`[];
160
161
  modifierTags: `@${string}`[];
@@ -610,6 +610,11 @@ function addTypeDocOptions(options) {
610
610
  ignoreUnescapedBraces: true,
611
611
  },
612
612
  });
613
+ options.addDeclaration({
614
+ name: "suppressCommentWarningsInDeclarationFiles",
615
+ help: (i18n) => i18n.help_lang(),
616
+ type: declaration_1.ParameterType.Boolean,
617
+ });
613
618
  options.addDeclaration({
614
619
  name: "commentStyle",
615
620
  help: (i18n) => i18n.help_commentStyle(),
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.26.1",
4
+ "version": "0.26.2",
5
5
  "homepage": "https://typedoc.org",
6
6
  "exports": {
7
7
  ".": "./dist/index.js",