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

[Bug]: React autodoc with JSDoc #30293

Open
spyx08 opened this issue Jan 17, 2025 · 2 comments
Open

[Bug]: React autodoc with JSDoc #30293

spyx08 opened this issue Jan 17, 2025 · 2 comments

Comments

@spyx08
Copy link

spyx08 commented Jan 17, 2025

Describe the bug

As React 19 is now stable and they don't support PropTypes and defaultProps anymore, we don't want to rewrite all our code to TypeScript, a good aternative is the JSDoc, so we migrated all our PropTypes and defaultProps to JSDoc.

But it seems the autodoc of storybook 8 with storybook/react-vite doesn't support or can't read the JSDoc, most of my type description on the storybook are now marked as "unknown" and also broke all the relative input controllers.

Image

Image

Reproduction link

https://codesandbox.io/p/devbox/priceless-snowflake-srk6t3?file=%2Fsrc%2Fstories%2FButton.jsx

Reproduction steps

/**
* @typedef {Object} Props
* @property {"primary"|"secondary"} variant - Variant color
* @property {boolean} [active=true] - Enable/Disable active
*
* @param {Props} props
* @returns {JSX.Element}
*/
const MyComponent=({variant,active=true}) => (...)

export default MyComponent;

System

System:
    OS: Windows 11 10.0.22631
    CPU: (24) x64 12th Gen Intel(R) Core(TM) i7-12800HX
  Binaries:
    Node: 20.17.0 - ~\Documents\node_v20\node.EXE
    npm: 10.8.2 - ~\Documents\node_v20\npm.CMD <----- active
  Browsers:
    Edge: Chromium (127.0.2651.74)
  npmPackages:
    @storybook/addon-essentials: ^8.4.7 => 8.4.7
    @storybook/addon-interactions: ^8.4.7 => 8.4.7
    @storybook/addon-links: ^8.4.7 => 8.4.7
    @storybook/blocks: ^8.4.7 => 8.4.7
    @storybook/preview-api: ^8.4.7 => 8.4.7
    @storybook/react: ^8.4.7 => 8.4.7
    @storybook/react-vite: ^8.4.7 => 8.4.7
    @storybook/test: ^8.4.7 => 8.4.7
    storybook: ^8.4.7 => 8.4.7

Additional context

No response

@shilman
Copy link
Member

shilman commented Jan 18, 2025

We'd like to modernize Storybook to support JSDoc types. In the meantime the (recommended but unsatisfying) workaround is to declare ArgTypes manually in your stories.

https://storybook.js.org/docs/api/arg-types

@spyx08
Copy link
Author

spyx08 commented Jan 20, 2025

@shilman Thank you, I also had a look for this aswell, but idk why, the argType type isnt taken into account, I still have unknown type when I force the type.

Image

Image

is that normal ?

Repro here:
https://codesandbox.io/p/devbox/priceless-snowflake-srk6t3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants