-
Notifications
You must be signed in to change notification settings - Fork 182
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
Unioned type for function param emits object
instead of inline type for type that is based on a typedef
#720
Comments
Thanks for detailed description. Fix in [email protected] It was a bit tricky to format this in a decent way but currently is produces this output. Please note output for parameter listings has changed a bit for readability. |
Hi @tgreyuk - Thanks for the quick response on this, greatly appreciated! Understood that the formatting gets complicated in this scenario, however I think the current in 4.3.0 is missing a key part of the type by not having a Repro: https://stackblitz.com/edit/vitejs-vite-8b5crt?file=src%2Findex.ts TypeDoc configuration In the case of handleFooExplicit, the generated result is: However, in the case of handleFoo, the generated result is: Even thought the types are defined in an identical way with the only difference being their "upstream" definitions: export const handleFoo = (a: Foo | null) => {};
export const handleFooExplicit = (a: FooExplicit | null) => {}; In the HTML version, the result is: Do you think it makes more sense and would it be possible to delimit |
Thanks @tgreyuk. Yeah, my preference would be Example 1 as it mirrors what the output is in the A few additional notes:
export const handleFooInline = (a: { a: string; b: string } | null) => {};
export const handleFooInlineMulti = (
a: { a: string; b: string } | { x: string; y: string } | null
) => {}; Generates the following MD which has two issues:
While the HTML equivalent generates: I believe the |
@techfg thanks for the comments - this kind of detailed feedback is invaluable and greatly appreciated.
Will review thank you.
You are correct, the html theme does not include further inlined declarations unless there are associated doc comments, in which case it does render the detailed declaration. This is a pattern i have considered implementing too but i found it more deterministic just retain the same behaviour regardless if comments are present. However on reflection there is obviously a case not to render this extended view if there is nothing useful to show (ie associated comments), and aligning with the html theme in this regard is probably the way to go.
Yes i thought about this too which is partly why the initial implementation was in blocks, however i think it can be implemented in a way that works, and if we are not displaying inline details all the time it becomes less of an issue. |
Happy to try to help @tgreyuk, glad your finding the feedback useful :) Makes sense about where you initially took the approach to always emit vs. only when comments are present. I do think that trying to mirror the HTML equivalent as much as possible may be the best course but understood if that presents challenges and I don't think it's worth bending over backwards to try to make that happen if its not straightforward enough. Just want to make sure you saw the comment about the issue where in the following, export const handleFooInlineMulti = (
a: { a: string; b: string } | { x: string; y: string } | null
) => {}; Thank you! |
As discussed - fixes in [email protected] |
Looking good in 4.3.1, thank you @tgreyuk! Only feedback I'd offer is that there is a |
spacing updated in |
Looks great, thanks for the quick response @tgreyuk! |
What package is the bug related to?
typedoc-plugin-markdown
Describe the issue
When a function parameter accepts a union type which contains a type that is based on a
typedef
, the type that was created viatypedef
emits asobject
instead of the inline type.Repro: https://stackblitz.com/edit/vitejs-vite-gkbey1
Steps to Reproduce
npm run docs:md
docs-md/functions
Actual Result
Generated markdown for function
handleFoo
which accepts the unionFoo | null
containsobject
for the type ofFoo
Additional Information
npm run docs:html
)handleFooOnly
- Does not contain a union, parama
is typeFoo
handleFoo2
- Defines a union typeFooExplicit
separately and uses it for the type parameter fora
instead of the inline unionhandleFooExplicit
- Uses a union type inline but does not usetypedef
TypeDoc configuration
typedoc: 0.26.11
typedoc-plugin-markdown: 4.2.10
typescript" 5.6.3
Expected behavior
The type
Foo
should be generated inline similar to the wayhandleFooOnly
which does not have a union type emits.The text was updated successfully, but these errors were encountered: