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
argTypes not generated correctly for Props of a TypeScript React Component with an Interface which extends another Type which uses ComponentProps and Pick #14798
Comments
Looks like I might have spoken too soon and it is (at least partially) an issue of In the example above one possible fix/workaround would be changing the interface to: import { ButtonProps as AntButtonProps } from 'antd';
export interface DefaultButtonProps {
size?: AntButtonProps['size'];
disabled?: AntButtonProps['disabled'];
icon?: AntButtonProps['icon'];
loading?: AntButtonProps['loading'];
onClick?: AntButtonProps['onClick'];
className?: AntButtonProps['className'];
/**
* Set primary style
*/
primary?: boolean;
/**
* Fit button to parent width
*/
stretch?: boolean;
} Which will generate the correct controls but is a lot more verbose. Going the more direct way of |
Running into this same issue. It would be nice if we didn't have to re-create types that simply link to existing types. |
Having the same issue here |
After some digging this worked for me:
|
Had a similar issue. Finally solved it with the following propFilter: (prop) => {
if (prop.name === 'children') {
return true;
}
if (prop.parent) {
return !/node_modules/.test(prop.parent?.fileName);
}
// Exclude native HTML props
if (!prop.declarations) {
return false;
}
return true;
}, |
I tried it but it didn't work for all components for example the Button component but for Autocomplete works well |
Describe the bug
In a Create React App TypeScript project I have a FunctionComponent with the following prop interface:
Storybook won't pick up these props correctly and only generate Controls & Doc Table entries for
primary
,stretch
and for some reasononClick
but the Control seems to be an Object definition (OnClick: {}
).I don't think that this is a
react-docgen-typescript
bug as I have run parse on this component directly and it seems to have generated the correct documentation.To Reproduce
Prerequisites:
antd
added to project & setup (add antd as a dependency and add the css import to your index.ts)Component with the issue:
The component returns and Ant Design button but only accepts a subset of the properties of that component and defines/renames some of them.
Running storybook will show the following props in Control and the Doc Table:
primary
,stretch
,onClick
whileonClick
has a JSON control withonClick: {}
.I tried running
react-docgen-typescript
directly on the file using:which results in the following output:
which looks correct(-ish?) in my eyes, so seemingly all the props got detected and parsed correctly but Storybook does not seem to use them correctly.
Maybe this is just a configuration issue on my side or Storybook does not detect some things correctly. I've added my
main.js
further below. It could also be that the issue lies somewhere completely different and not the exotic typing.System
Additional context
Storybook launch command:
start-storybook -p 6006 -s public
.storybook/main.js
:I have various configurations to add import aliases, different ant themes based on flavor (it's a white labeled app), and ant design. I've included nearly everything so it should be easier to find the issue if it's simply a config issue.
preview.js
is only slightly modified, 2 decorators for Suspense and i18n Providers and a globalTypes export for a Locale change button:The text was updated successfully, but these errors were encountered: