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

parameter type emitted as object instead of inline type #745

Closed
techfg opened this issue Dec 22, 2024 · 8 comments
Closed

parameter type emitted as object instead of inline type #745

techfg opened this issue Dec 22, 2024 · 8 comments
Labels
bug Issue raised as a bug.

Comments

@techfg
Copy link

techfg commented Dec 22, 2024

What package is the bug related to?

typedoc-plugin-markdown

Describe the issue

In certain scenarios, the type emitted for a function parameter that is a type is emitted as object instead of the inline type.

A few notes:

  1. This is very similar to the issues mentioned in property emits object for its type instead of inlined typed #733 & Unioned type for function param emits object instead of inline type for type that is based on a typedef #720.
  2. None of the issues occur when generating html (typedoc-plugin-markdown is not used)
  3. There are three scenarios outlined in the repro:
    1. type based on typedef - all doesNotWork* functions emit object for the opts param type
    2. explicit type - No issues, everything works as expected
    3. explicit type with @inline tag - all doesNotWork* functions emit object for the opts param type
  4. Adding strict=true to tsconfig.json changes the behavior:
    1. type based on typedef - doesNotWorkDefault and doesNotWork2 emit correctly but doesNotWork1 does not
    2. explicit type - No change, everything still works
    3. explicit type with @inline tag - doesNotWorkDefault and doesNotWork2 emit correctly but doesNotWork1 does not

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

npm run docs:md && npm run docs:html

image

TypeDoc configuration

    "typedoc": "^0.27.5",
    "typedoc-plugin-markdown": "^4.3.3",
    "typescript": "^5.7.2",

Expected behavior

full type should emit inline in all cases for scenario 1 & 3.

@tgreyuk
Copy link
Member

tgreyuk commented Dec 22, 2024

thanks @techfg - i will go through each of these use-cases.

@techfg
Copy link
Author

techfg commented Dec 23, 2024

thanks @tgreyuk! Very odd about why strict changes the behavior in 2 of the 3 scenarios, looking forward to hearing what you find 😄

@tgreyuk
Copy link
Member

tgreyuk commented Dec 30, 2024

@techfg fixes for above in typedoc-plugin-markdown@4.4.0.

Tested against both strict: true|false (not entirely sure what causes the side effects here).

@techfg
Copy link
Author

techfg commented Dec 31, 2024

Thanks for the update @tgreyuk! Unfortunately, it appears that some situations are still not working as expected.

  1. type based on typedef
    1. When strict is enabled, all works as expected
    2. When strict is NOT enabled, doesNotWorkDefault and doesNotWork2 emit object. I ran this a few times and I believe I also saw doesNotWork1 emit object but am not able to reproduce it currently so possibly I mid-read the output.
  2. explicit type - No issues, everything works as expected
  3. explicit type with @inline tag
    1. When strict is enabled, all works as expected
    2. When strict is NOT enabled, doesNotWorkDefault and doesNotWork2 emit object.

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

@tgreyuk
Copy link
Member

tgreyuk commented Dec 31, 2024

@techfg - sorry - not sure what happened with my testing there. I understand now though. When strict=false, the type is parsed as an OptionalType, which wasn't correctly handling the object expansion. However, when strict=true, the type is parsed as a UnionType that includes a null item which was being handled correctly.

I do have a fix. I will plan to release a.s.a.p - probably tomorrow.

@techfg
Copy link
Author

techfg commented Dec 31, 2024

No worries, thank you! And good to better understand why strict makes a difference 😄

@tgreyuk
Copy link
Member

tgreyuk commented Jan 1, 2025

Hopefully resolved in typedoc-plugin-markdown@4.4.1

@techfg
Copy link
Author

techfg commented Jan 1, 2025

all 3 scenarios look good in v4.4.1 regardless of strict setting.

Thank you @tgreyuk!

@tgreyuk tgreyuk closed this as completed Jan 1, 2025
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.
Projects
None yet
Development

No branches or pull requests

2 participants