typedoc icon indicating copy to clipboard operation
typedoc copied to clipboard

Cannot link to `default` property

Open dsogari opened this issue 11 months ago • 1 comments

Search terms

link, default

Expected Behavior

It should generate the docs.

Actual Behavior

It outputs:

[warning] Failed to resolve link to "Test.default" in comment for Test.__type.other.

Steps to reproduce the bug

  1. Create a package.json file with the following contents:
{
  "name": "test",
  "version": "0.1.0"
}
  1. Create an index.ts file with the following contents:
/** Test */
export type Test = {
  /** Default */
  readonly default: string;
  /** {@link Test.default} */
  readonly other: string;
}
  1. Run the following commands:
npm install --save-dev typedoc typescript
npm exec typedoc index.ts

Environment

  • Typedoc version: 0.25.12
  • TypeScript version: 5.4.2
  • Node.js version: v20.11.0
  • OS: Linux 5.15.146.1-microsoft-standard-WSL2 x86_64 x86_64

dsogari avatar Mar 15 '24 01:03 dsogari

This is because TypeScript doesn't resolve that link.

image

The only reason that linking to other doesn't generate a warning is because TypeScript resolves it. TypeDoc's custom link resolution doesn't support resolving links to properties of type aliases.

In fact, while {@link Test.other} doesn't generate a warning, it also doesn't actually work. It will generate a link to Test.html#__type.other, but the __type.other anchor does not exist on the page. This needs to be fixed before the default issue.

Gerrit0 avatar Mar 16 '24 18:03 Gerrit0