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

addon-docs: Props table can't find props when using ComponentProps<typeof X>. #9922

Closed
etlovett opened this issue Feb 21, 2020 · 5 comments
Closed

Comments

@etlovett
Copy link
Contributor

Describe the bug
When using addon-docs with Storybook, the props table says that it cannot find any props for a component that uses ComponentProps<typeof OtherComponent> in its type definition.

To Reproduce
Steps to reproduce the behavior:

  1. Clone https://github.com/etlovett/storybook-bug-repros/tree/with-other-component-props.
    1. As you can see from the commit history, this repo/branch is create-react-app in TypeScript, plus Storybook in TypeScript, plus addon-docs, with a local copy of the demo button and a WrappedButton component that uses it internally and wishes to proxy props to it.
  2. Run yarn storybook.
  3. Go to the WrappedButton page.
  4. See that the props table says "No props found for this component".

Expected behavior
I would expect the props table to list the spacing prop from WrappedButton and the onClick prop from Button.

Note that if you remove the & ComponentProps<typeof Button> the props table will correctly show the spacing prop, so it's clearly related to this intersection. If you do type Props = ComponentProps<typeof Button>, then the table is still empty. It therefore seems like the props table is unable to show props when ComponentProps<typeof X> is part of the type definition.

Interestingly, if I import Button via import { Button } from '@storybook/react/demo'; rather than using the local clone of that file, both spacing and onClick correctly show up in the props table.

Code snippets
The Props type definition that I'd like to use:

type Props = {
  spacing: number
} & ComponentProps<typeof Button>;

System:

Environment Info:

  System:
    OS: macOS 10.15.3
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 13.7.0 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
  Browsers:
    Safari: 13.0.5
  npmPackages:
    @storybook/addon-actions: ^5.3.13 => 5.3.13
    @storybook/addon-docs: ^5.3.13 => 5.3.13
    @storybook/addon-links: ^5.3.13 => 5.3.13
    @storybook/addons: ^5.3.13 => 5.3.13
    @storybook/preset-create-react-app: ^1.5.2 => 1.5.2
    @storybook/react: ^5.3.13 => 5.3.13

Thanks for building a great tool!

shilman added a commit that referenced this issue Feb 21, 2020
@shilman
Copy link
Member

shilman commented Feb 21, 2020

@etlovett Thanks for the bug report! I've created a repro at #9924

As you can see from the snapshots, this is an issue with one of the libraries we're using. I'm still working out the protocol for filing issues on libraries we depend on, but will follow up on this once I've figured that out.

@etlovett
Copy link
Contributor Author

To be honest I don't understand what's captured by the snapshots well enough to see that in them, but that had certainly been my assumption. I filed it here rather than against the dependency because I saw a bunch of other related bugs for which you'd created repro cases and otherwise seemed to have "accepted" them.

Thanks!

@etlovett
Copy link
Contributor Author

@shilman Is there something we should do to keep the stale bot from closing this?

@stale stale bot removed the inactive label Mar 14, 2020
@shilman shilman added the todo label Mar 15, 2020
@storybookjs storybookjs deleted a comment from stale bot Mar 15, 2020
@shilman
Copy link
Member

shilman commented Mar 15, 2020

i've marked it as todo to keep it from being automatically closed. that said, i use the stale bot as a kind of "snooze alarm" for issues that we can't get to right away, so it's actually useful to get the reminders.

In this case the 6.0 react-docgen setup has made some progress, and is now the default for the CRA setup. it's documented here:

https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#react-prop-tables-with-typescript

Next steps, I think, is to file a bug in react-docgen, and then document it in the "known issues" https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/props-tables.md#react

Would you be up for giving that a shot?

@shilman
Copy link
Member

shilman commented Jun 7, 2023

We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid.

Please open a new issue referencing this one if:

@shilman shilman closed this as completed Jun 7, 2023
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