-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Typescript extended props not show v6 #12129
Comments
Try adding this to main.js: typescript: {
reactDocgen: 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
compilerOptions: {
allowSyntheticDefaultImports: false,
esModuleInterop: false,
},
}
} |
@petermikitsh should either of those options be made default? |
It seems like just having this works, so it must some misconfiguration internally
|
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
These are the defaults. It's probably because it's excluding I think excluding Perhaps we need to make it easier to enable that, as a flag? Or just improve the documentation? What do you think? |
Does the above go inside of I don't see any props that have been extended. |
@awkale yes |
A recent pull request #12841 was created to adjust the documentation and include a bit more of context regarding the issue. Let me know if you're ok with it and any additional feedback is welcome. Stay safe |
Chore: update documentation to address issue #12129
Chore: update documentation to address issue #12129
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
I'm having the same problem right now, using the material ui, is anyone working on it? |
This suggest is working for me, however it exposes every HTML prop as well, making the storybook ui unusable since each component now has close to 300 props. |
@natac13 the |
I attempted to get the props using the
|
Personally, it only seemed to work for me with this configuration. Having the additional two booleans in there would break it. Unfortunately, having this new config brings in the props I wanted, but it wrecks some other controls I have (such as limiting another prop to a couple of options). |
Currently we're using Storybook 6.2.9 with Material UI 4.12.0 and the below configuration works flawlessly for us. It renders all the MUI props properly and ignores all the default HTML props. The two key changes for us were the module.exports = {
stories: ["../src/**/*.stories.@(ts|tsx|js|jsx)"],
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
typescript: {
check: true,
reactDocgen: "react-docgen-typescript",
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: (prop) =>
prop.parent
? /@material-ui/.test(prop.parent.fileName) || !/node_modules/.test(prop.parent.fileName)
: true,
compilerOptions: {
allowSyntheticDefaultImports: false,
},
},
},
} |
None of those works for me, some props are extended and created correctly. For example for Button, but for a lot of components I'm getting some useless garbage and not correct props for example Alert. Any solution for this? |
Maybe it a little bit tricky but I found temporary solution to generate only material ui props and ignore all of HTML props.
|
Having the same problem here |
How does your button story look like? I tried with your example and the following story. But the args table is still not generated (it works for non mui components)
|
The configuration from @mstosio works for me. I however also need to create named exports for mui components instead of a default export (this is mentioned on the Storybook TypeScript docs as well). So I create a file
And then import the I hope this helps. |
Try to import ButtonProps from Material UI. I think you are missing this part. |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
did anyone tried this in Mui 5. I have added additional properties in theme like below
I can see and use the additional variants through the code, but not in storybook I am using React: 17 |
Nice one and works fine, thanks a lot. Do we have an official solution now? |
Even though the code forces
It didn't work out of the box for me and I needed to add it manually module.exports = {
typescript: {
// https://github.com/storybookjs/storybook/issues/12129#issuecomment-921878013
reactDocgen: "react-docgen-typescript",
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
savePropValueAsString: true, // <--- here
propFilter: prop => true /* your filter */
},
},
} |
Oh actually it was |
If anyone is looking for a solution working with ant-design & react-docgen-typescript. The following solves the issue:
|
I am having a similar problem to @krishnans with my own extended MUI 5 Theme I extended my theme like this:
My Storybook main.js file looks like this:
And my Button.tsx component file looks like this:
With this result, where myCustomColor is not shown in the color dropdown options: I am using: |
Any luck? i am still not getting all MUI props in storybook UI. |
@shubham799 I kinda worked around this by using SB Referring to the color problem above, this is how we solved it:
|
This still happens and since there's no way determining the cause, this is rather frustrating. I checked with all configurations shown above, and nothing works as expected (1) props are shown, 2) with their correct control types and 3) possible values) - since MUI is (by far) the largest React component library, this is something really worth being investigated / documented, because the docs don't work 😭 |
@integrayshaun — Mind looking into this? It appears the MUI recipe doesn't work for all setups? If someone here can provide a simplified reproduction (https://storybook.new is great for this), that would be a big help. Thanks! |
Hey folks, here's an updated example repo for the material UI recipe to help you on your way. If you have more questions, let me know and i'll work on making it clearer https://stackblitz.com/edit/github-ju9knk?file=.storybook/preview.ts |
My
|
@yarinsa thanks for solution |
I tried using this and it works for module augmentation. The key is the include option below. My declaration file is named styles.d.ts. You have to include it for storybook to take into account the augmented styles. Hope it helps someone const config: StorybookConfig = {
typescript: {
check: false,
reactDocgen: 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
include: ['**/**.tsx', 'src/themes/styles.d.ts'],
shouldExtractLiteralValuesFromEnum: true,
skipChildrenPropWithoutDoc: false,
shouldRemoveUndefinedFromOptional: true,
tsconfigPath: './tsconfig.json',
compilerOptions: {
allowSyntheticDefaultImports: false,
esModuleInterop: false,
},
propFilter: (prop) =>
prop.parent
? /@material-ui/.test(prop.parent.fileName) ||
!/node_modules/.test(prop.parent.fileName)
: true,
},
},
...
}; |
I'm still struggling to get it working with |
Can you provide me a repro with |
@mstosio thanks. It helps me, but it adds an undefined value each time. Is there a solution to prevent this undefined value? |
> }, @adirzoari try add shouldRemoveUndefinedFromOptional: true to ur config |
Describe the bug
Define typescript props for component with extending other props, doesn't show the extended props.
For example a component with
Produces the following
Expected behavior
Its suppose to show all the props valid for the component such as type, max, min e.t.c
System:
The text was updated successfully, but these errors were encountered: