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]: Type errors in stories where component has discriminated union in its prop type definition, and custom properties are used #30379

Open
selrond opened this issue Jan 24, 2025 · 2 comments

Comments

@selrond
Copy link
Contributor

selrond commented Jan 24, 2025

Describe the bug

It seems to be impossible to properly type a story, when a component

  1. has discriminated union in its props type definition, and
  2. its story contains custom storybook-only property

Reproduction link

https://stackblitz.com/edit/storybook-type-errors?file=src%2Fstories%2FComponent.tsx,src%2Fstories%2FComponent.stories.tsx

Reproduction steps

No response

System

Storybook Environment Info:

  System:
    OS: macOS 15.2
    CPU: (14) arm64 Apple M4 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.11.0 - ~/.local/state/fnm_multishells/52967_1737709857083/bin/node
    npm: 10.9.0 - ~/.local/state/fnm_multishells/52967_1737709857083/bin/npm
    pnpm: 9.14.2 - ~/.local/state/fnm_multishells/52967_1737709857083/bin/pnpm <----- active
  Browsers:
    Chrome: 132.0.6834.110
    Safari: 18.2
  npmPackages:
    @storybook/addon-docs: ^8.6.0-alpha.2 => 8.6.0-alpha.2
    @storybook/addon-essentials: ^8.6.0-alpha.2 => 8.6.0-alpha.2
    @storybook/addon-interactions: ^8.6.0-alpha.2 => 8.6.0-alpha.2
    @storybook/addon-themes: ^8.6.0-alpha.2 => 8.6.0-alpha.2
    @storybook/blocks: ^8.6.0-alpha.2 => 8.6.0-alpha.2
    @storybook/nextjs: ^8.6.0-alpha.2 => 8.6.0-alpha.2
    @storybook/react: ^8.6.0-alpha.2 => 8.6.0-alpha.2
    @storybook/test: ^8.6.0-alpha.2 => 8.6.0-alpha.2
    eslint-plugin-storybook: ^0.11.2 => 0.11.2
    storybook: ^8.6.0-alpha.2 => 8.6.0-alpha.2

Additional context

Originally found on v8.5.0 of storybook packages, tried to upgrade to latest versions to see if it’s fixed.

@selrond
Copy link
Contributor Author

selrond commented Jan 24, 2025

Maybe related to this #25492

@valentinpalkovic
Copy link
Contributor

Hi @selrond

Thank you for reporting the issue.

Can you please try using react-docgen-typescript instead of react-docgen for getting the proper type extracted from your component? Resource: https://storybook.js.org/docs/configure/integration/typescript#the-types-are-not-being-generated-for-my-component

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