typedoc: Nested parameter not rendered when top parameter is optional
- I have checked issues with bug label and found no duplicates
Expected Behavior
This snippet should render the nested parameter value
correctly in the HTML output:
/**
* @param options RootParameter
* @param options.under NestedParameter
*/
export function under(options?: {under: boolean}) {}
More Information
The bug is caused because in strict mode, this snippet get’s rendered as an union type of the form { ... } | undefined
. It seems typedoc will not render the nested parameters in this case.
This test case fails also even when strict: false
:
/**
* @param options RootParameter
* @param options.under NestedParameter
*/
export function under(options: {under: boolean} | undefined) {}
Would you accept a PR that cover this cases (I would extend it to null/both cases also ... | null, ... | undefined, ... | null | undefined
).
Actual Behavior
The nested parameter should be rendered.
Steps to reproduce the bug
See https://github.com/maoueh/typedoc-bug-1020-repro
- Define the snippet above in a file.
- Ensure
strict: true
(this generates a union type from the parser point of view) - Inspect HTML, output is not rendered correctly.
Environment
- Typedoc version: 0.14.2
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 17
That could certainly use some improvement, feel free to open a new issue 😃
I really want to completely rebuild the default theme. I think there is some major room for improvement in rendering the types in an easily understandable way, the nested lists used right now work, but get unwieldy… Unfortunately I don’t think I’ll get to this for a while…
Fixed in typedoc-default-themes@0.7.1. If you install without a lockfile it should be picked up, or v0.16.3 (out later today) will pull this in.
Turns out the information to render everything was already there (partially due to the changes done to exports), but the themes weren’t updated to support it.
If you are using a custom theme that has changed the
type.hbs
helper, it will need to pull in changes from typedoc-default-themes@0.7.1 to get this.Rendering is tricky. There are cases when dealing with unions/intersections, conditional types, and function types where you have to be very careful to avoid generating an invalid type. I think I’ve caught all the edge cases, but it’s possible I missed one.
That’s unfortunate 😕 I thought the changes to exports would have fixed that.