typedoc 0.28.10 → 0.28.11

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.
@@ -409,7 +409,7 @@ let Application = (() => {
409
409
  if (!supportedVersionMajorMinor.some((version) => version == ts.versionMajorMinor)) {
410
410
  this.logger.warn(i18n.unsupported_ts_version_0(supportedVersionMajorMinor.join(", ")));
411
411
  }
412
- if (Object.keys(this.options.getCompilerOptions()).length === 0) {
412
+ if (Object.keys(this.options.getCompilerOptions(this.logger)).length === 0) {
413
413
  this.logger.warn(i18n.no_compiler_options_set());
414
414
  }
415
415
  // Doing this is considerably more complicated, we'd need to manage an array of programs, not convert until all programs
@@ -429,7 +429,7 @@ let Application = (() => {
429
429
  // We don't want to do it the first time to preserve initial debug status messages. They'll be lost
430
430
  // after the user saves a file, but better than nothing...
431
431
  let firstStatusReport = true;
432
- const host = ts.createWatchCompilerHost(tsconfigFile, this.options.fixCompilerOptions({}), ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram, (d) => diagnostic(this.logger, d), (status, newLine, _options, errorCount) => {
432
+ const host = ts.createWatchCompilerHost(tsconfigFile, this.options.fixCompilerOptions({}, this.logger), ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram, (d) => diagnostic(this.logger, d), (status, newLine, _options, errorCount) => {
433
433
  if (!firstStatusReport &&
434
434
  errorCount === void 0 &&
435
435
  !this.options.getValue("preserveWatchOutput") &&
@@ -263,9 +263,7 @@ function findJsDocForComment(node, ranges) {
263
263
  .map((doc) => ts.findAncestor(doc, ts.isJSDoc));
264
264
  if (ts.isSourceFile(node)) {
265
265
  if (node.statements.length) {
266
- jsDocs.push(...ts
267
- .getJSDocCommentsAndTags(node.statements[0])
268
- .map((doc) => ts.findAncestor(doc, ts.isJSDoc)));
266
+ jsDocs.push(...node.statements[0].getChildren().filter(ts.isJSDoc));
269
267
  }
270
268
  }
271
269
  return jsDocs.find((doc) => doc.pos === ranges[0].pos);
@@ -405,6 +403,19 @@ function declarationToCommentNodes(node, checker) {
405
403
  inheritedFromParentDeclaration: true,
406
404
  });
407
405
  }
406
+ // #2999 automatically pick up comments from the value symbol for shorthand assignments
407
+ if (ts.isShorthandPropertyAssignment(node)) {
408
+ const sourceSymbol = checker.getShorthandAssignmentValueSymbol(node);
409
+ if (sourceSymbol?.valueDeclaration) {
410
+ const commentNode = declarationToCommentNodeIgnoringParents(sourceSymbol.valueDeclaration);
411
+ if (commentNode) {
412
+ result.push({
413
+ node: commentNode,
414
+ inheritedFromParentDeclaration: true,
415
+ });
416
+ }
417
+ }
418
+ }
408
419
  // With overloaded functions/methods, TypeScript will use the comment on the first signature
409
420
  // declaration
410
421
  if ((ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node)) &&
@@ -144,6 +144,7 @@ module.exports = {
144
144
  invalid_tsdoc_json_0: `The file {0} is not a valid tsdoc.json file`,
145
145
  options_file_0_does_not_exist: `The options file {0} does not exist`,
146
146
  failed_read_options_file_0: `Failed to parse {0}, ensure it exists and exports an object`,
147
+ failed_to_apply_compilerOptions_overrides_0: "Failed to apply compilerOptions overrides: {0}",
147
148
  // plugins
148
149
  invalid_plugin_0_missing_load_function: `Invalid structure in plugin {0}, no load function found`,
149
150
  plugin_0_could_not_be_loaded: `The plugin {0} could not be loaded`,
@@ -360,7 +361,7 @@ module.exports = {
360
361
  // Page headings/labels
361
362
  theme_implements: "Implements",
362
363
  theme_indexable: "Indexable",
363
- theme_type_declaration: "Type declaration",
364
+ theme_type_declaration: "Type Declaration",
364
365
  theme_index: "Index",
365
366
  theme_hierarchy: "Hierarchy",
366
367
  theme_hierarchy_summary: "Hierarchy Summary",
@@ -133,6 +133,7 @@ declare const _default: {
133
133
  readonly invalid_tsdoc_json_0: "The file {0} is not a valid tsdoc.json file";
134
134
  readonly options_file_0_does_not_exist: "The options file {0} does not exist";
135
135
  readonly failed_read_options_file_0: "Failed to parse {0}, ensure it exists and exports an object";
136
+ readonly failed_to_apply_compilerOptions_overrides_0: "Failed to apply compilerOptions overrides: {0}";
136
137
  readonly invalid_plugin_0_missing_load_function: "Invalid structure in plugin {0}, no load function found";
137
138
  readonly plugin_0_could_not_be_loaded: "The plugin {0} could not be loaded";
138
139
  readonly help_options: "Specify a json option file that should be loaded. If not specified TypeDoc will look for 'typedoc.json' in the current directory";
@@ -336,7 +337,7 @@ declare const _default: {
336
337
  readonly flag_inherited: "Inherited";
337
338
  readonly theme_implements: "Implements";
338
339
  readonly theme_indexable: "Indexable";
339
- readonly theme_type_declaration: "Type declaration";
340
+ readonly theme_type_declaration: "Type Declaration";
340
341
  readonly theme_index: "Index";
341
342
  readonly theme_hierarchy: "Hierarchy";
342
343
  readonly theme_hierarchy_summary: "Hierarchy Summary";
@@ -566,6 +566,7 @@ export class FormattedCodeBuilder {
566
566
  const id = this.newId();
567
567
  return group(id, [
568
568
  name,
569
+ sig.parent.flags.isOptional ? simpleElement(JSX.createElement("span", { class: "tsd-signature-symbol" }, "?")) : emptyNode,
569
570
  this.typeParameters(sig),
570
571
  ...this.parameters(sig, id),
571
572
  nodes(options.arrowStyle ? space() : emptyNode, simpleElement(JSX.createElement("span", { class: "tsd-signature-symbol" }, options.arrowStyle ? "=>" : ":")), space(), this.type(sig.type, TypeContext.none)),
@@ -1,4 +1,4 @@
1
- import type { DeclarationReflection } from "../../../../models/index.js";
1
+ import type { DeclarationReflection } from "#models";
2
2
  import { JSX } from "#utils";
3
3
  import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext.js";
4
4
  export declare function memberDeclaration(context: DefaultThemeRenderContext, props: DeclarationReflection): JSX.Element;
@@ -1,30 +1,32 @@
1
1
  import { JSX } from "#utils";
2
2
  import { FormattedCodeBuilder, FormattedCodeGenerator, Wrap } from "../../../formatter.js";
3
3
  import { hasTypeParameters } from "../../lib.js";
4
+ function shouldRenderDefaultValue(props) {
5
+ const defaultValue = props.defaultValue;
6
+ if (defaultValue === undefined) {
7
+ return false;
8
+ }
9
+ /** Fix for #2717. If type is the same as value the default value is omitted */
10
+ if (props.type && props.type.type === "literal") {
11
+ const reflectionTypeString = props.type.toString();
12
+ if (reflectionTypeString === defaultValue.toString()) {
13
+ return false;
14
+ }
15
+ }
16
+ return true;
17
+ }
4
18
  export function memberDeclaration(context, props) {
5
19
  const builder = new FormattedCodeBuilder(context.router, context.model);
6
20
  const content = [];
7
21
  builder.member(content, props, { topLevelLinks: false });
8
22
  const generator = new FormattedCodeGenerator(context.options.getValue("typePrintWidth"));
9
23
  generator.node({ type: "nodes", content }, Wrap.Detect);
10
- /** Fix for #2717. If type is the same as value the default value is omitted */
11
- function shouldRenderDefaultValue() {
12
- if (props.type && props.type.type === "literal") {
13
- const reflectionTypeString = props.type.toString();
14
- const defaultValue = props.defaultValue;
15
- if (defaultValue === undefined || reflectionTypeString === defaultValue.toString()) {
16
- return false;
17
- }
18
- }
19
- return true;
20
- }
21
24
  return (JSX.createElement(JSX.Fragment, null,
22
25
  JSX.createElement("div", { class: "tsd-signature" },
23
26
  generator.toElement(),
24
- !!props.defaultValue && shouldRenderDefaultValue() && (JSX.createElement(JSX.Fragment, null,
25
- JSX.createElement("span", { class: "tsd-signature-symbol" },
26
- " = ",
27
- props.defaultValue)))),
27
+ shouldRenderDefaultValue(props) && (JSX.createElement("span", { class: "tsd-signature-symbol" },
28
+ " = ",
29
+ props.defaultValue))),
28
30
  context.commentSummary(props),
29
31
  hasTypeParameters(props) && context.typeParameters(props.typeParameters),
30
32
  props.type && context.typeDeclaration(props, props.type),
@@ -214,7 +214,7 @@ function getEntryPointsForPaths(logger, inputFiles, options, programs = getEntry
214
214
  return entryPoints;
215
215
  }
216
216
  export function getExpandedEntryPointsForPaths(logger, inputFiles, options, programs = getEntryPrograms(inputFiles, logger, options)) {
217
- const compilerOptions = options.getCompilerOptions();
217
+ const compilerOptions = options.getCompilerOptions(logger);
218
218
  const supportedFileRegex = compilerOptions.allowJs || compilerOptions.checkJs
219
219
  ? /\.([cm][tj]s|[tj]sx?)$/
220
220
  : /\.([cm]ts|tsx?)$/;
@@ -252,14 +252,14 @@ function getEntryPrograms(inputFiles, logger, options) {
252
252
  const rootProgram = noTsConfigFound
253
253
  ? ts.createProgram({
254
254
  rootNames: inputFiles,
255
- options: options.getCompilerOptions(),
255
+ options: options.getCompilerOptions(logger),
256
256
  })
257
257
  : ts.createProgram({
258
258
  rootNames: options.getFileNames(),
259
- options: options.getCompilerOptions(),
259
+ options: options.getCompilerOptions(logger),
260
260
  projectReferences: options.getProjectReferences(),
261
261
  });
262
- addInferredDeclarationMapPaths(options.getCompilerOptions(), options.getFileNames());
262
+ addInferredDeclarationMapPaths(options.getCompilerOptions(logger), options.getFileNames());
263
263
  const programs = [rootProgram];
264
264
  // This might be a solution style tsconfig, in which case we need to add a program for each
265
265
  // reference so that the converter can look through each of these.
@@ -270,7 +270,7 @@ function getEntryPrograms(inputFiles, logger, options) {
270
270
  if (!ref)
271
271
  continue; // This indicates bad configuration... will be reported later.
272
272
  programs.push(ts.createProgram({
273
- options: options.fixCompilerOptions(ref.commandLine.options),
273
+ options: options.fixCompilerOptions(ref.commandLine.options, logger),
274
274
  rootNames: ref.commandLine.fileNames,
275
275
  projectReferences: ref.commandLine.projectReferences,
276
276
  }));
@@ -1,4 +1,4 @@
1
- import type ts from "typescript";
1
+ import ts from "typescript";
2
2
  import type { Application } from "../../../index.js";
3
3
  import { type DeclarationOption, type KeyToDeclaration, type TypeDocOptionMap, type TypeDocOptions, type TypeDocOptionValues } from "./declaration.js";
4
4
  import { type Logger, type NeverIfInternal } from "#utils";
@@ -156,9 +156,9 @@ export declare class Options {
156
156
  /**
157
157
  * Gets the set compiler options.
158
158
  */
159
- getCompilerOptions(): ts.CompilerOptions;
159
+ getCompilerOptions(logger: Logger): ts.CompilerOptions;
160
160
  /** @internal */
161
- fixCompilerOptions(options: Readonly<ts.CompilerOptions>): ts.CompilerOptions;
161
+ fixCompilerOptions(options: Readonly<ts.CompilerOptions>, logger: Logger): ts.CompilerOptions;
162
162
  /**
163
163
  * Gets the file names discovered through reading a tsconfig file.
164
164
  */
@@ -1,3 +1,4 @@
1
+ import ts from "typescript";
1
2
  import { resolve } from "path";
2
3
  import { ParameterType } from "./declaration.js";
3
4
  import { normalizePath } from "../paths.js";
@@ -185,15 +186,25 @@ export class Options {
185
186
  /**
186
187
  * Gets the set compiler options.
187
188
  */
188
- getCompilerOptions() {
189
- return this.fixCompilerOptions(this._compilerOptions);
189
+ getCompilerOptions(logger) {
190
+ return this.fixCompilerOptions(this._compilerOptions, logger);
190
191
  }
191
192
  /** @internal */
192
- fixCompilerOptions(options) {
193
+ fixCompilerOptions(options, logger) {
193
194
  const overrides = this.getValue("compilerOptions");
194
195
  const result = { ...options };
195
196
  if (overrides) {
196
- Object.assign(result, overrides);
197
+ const tsOptions = ts.convertCompilerOptionsFromJson(overrides, ".", "typedoc-overrides.json");
198
+ if (tsOptions.errors.length) {
199
+ for (const error of tsOptions.errors) {
200
+ logger.error(i18n.failed_to_apply_compilerOptions_overrides_0(ts.flattenDiagnosticMessageText(error.messageText, "\n")));
201
+ }
202
+ }
203
+ else {
204
+ for (const key in overrides) {
205
+ result[key] = tsOptions.options[key];
206
+ }
207
+ }
197
208
  }
198
209
  if (this.getValue("emit") !== "both") {
199
210
  result.noEmit = true;
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.10",
4
+ "version": "0.28.11",
5
5
  "homepage": "https://typedoc.org",
6
6
  "type": "module",
7
7
  "exports": {