Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type for optional array element not hyperlinked #719

Closed
techfg opened this issue Nov 23, 2024 · 4 comments
Closed

Type for optional array element not hyperlinked #719

techfg opened this issue Nov 23, 2024 · 4 comments
Labels
bug Issue raised as a bug. fixed Fix implemented in latest version.

Comments

@techfg
Copy link

techfg commented Nov 23, 2024

What package is the bug related to?

typedoc-plugin-markdown

Describe the issue

For a function that accepts an array of optional elements, the type of the element is not hyperlinked in the generated markdown doc.

For example, given:

export type Stuff = { a: string; b: string };
export const handleArrayOfOptionalStuff = (a: [Stuff?]) => {};

The generated markdown will be:

• **a**: [`Stuff?`]

Repro: https://stackblitz.com/edit/vitejs-vite-nypddu

Steps to Reproduce

  1. Open repro
  2. npm run docs:md
  3. View files in docs-md/functions

Actual Result
Generated markdown "links" the type Stuff for handleStuff, handleOptionalStuff, handleArrayOfStuff but not for handleArrayOfOptionalStuff

Additional Information

  1. The issue does not occur when generating html files (npm run docs:html)
  2. The issue does not occur for optional parameters, only arrays with optional elements

TypeDoc configuration

typedoc: 0.26.11
typedoc-plugin-markdown: 4.2.10
typescript" 5.6.3

Expected behavior

The generated markdown should contain a hyperlink to Stuff:

• **a**: [[`Stuff`](../type-aliases/Stuff.md)]
@techfg techfg added the bug Issue raised as a bug. label Nov 23, 2024
@tgreyuk
Copy link
Member

tgreyuk commented Nov 27, 2024

Thanks for detailed description.

Fix in typedoc-plugin-markdown@4.3.0

Screenshot 2024-11-27 at 18 29 00

https://github.com/typedoc2md/typedoc-plugin-markdown-scratchpad/blob/main/issues/719/docs/md/functions/handleArrayOfStuff.md

Please note parameters layout has been tweaked in listing view to make a bit clearer. For a concise view parametersFormat-table can be used.

@tgreyuk tgreyuk added the fixed Fix implemented in latest version. label Nov 27, 2024
@techfg
Copy link
Author

techfg commented Nov 27, 2024

Hi @tgreyuk -

Thanks for the quick response on this, greatly appreciated!

In the repro provided, all looks good! Unfortunately, when the type includes union and the entire union itself is optional, the docs do not emit correctly.

Repro: https://stackblitz.com/edit/vitejs-vite-vyxrtv?file=src%2Findex.ts

TypeDoc configuration
typedoc: 0.27.0
typedoc-plugin-markdown: 4.3.0
typescript" 5.7.2

export const handleArrayOfOptionalStuff = (
  a: [(null | undefined | Stuff)?]
) => {};

Actual Result
image

### a

[`null` \| [`Stuff`](../type-aliases/Stuff.md)?]

Expected Result
image

### a

[(`null` \| [`Stuff`](../type-aliases/Stuff.md))?]

Actual HTML Result
image

@tgreyuk
Copy link
Member

tgreyuk commented Dec 1, 2024

Fix in typedoc-plugin-markdown@4.3.1

Screenshot 2024-12-01 at 23 14 33

@techfg
Copy link
Author

techfg commented Dec 2, 2024

Looks great in 4.3.1, thank you @tgreyuk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue raised as a bug. fixed Fix implemented in latest version.
Projects
None yet
Development

No branches or pull requests

2 participants