-
-
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
Addons info and Typescript props docgen? #1519
Comments
@pselden You are more than welcome to open a PR to get that integrated. There is no current way of getting Typescript into the prop tables. |
@pselden did you ever solve this? |
No I have not solved it, unfortunately. |
to have the props shown properly I'm just declaring them like so
inside my class, which is redundant with the interface declaration but I don't mind since it provides nicer documentation |
Same issue for me. Any news about that? 📬 |
Any news about that? |
This would be great to have |
we now use storybook and typescript at work. i would be interested in working on a PR for this, but i do need some help as I am completely new to this codebase. any pointers on where would I start and any prior art I can look at? |
@tsiq-swyx You can see how the data inserted by the plugin is used by reviewing the components here: Stylegusiest has a docgen for TypeScript. It makes use of the TypeScript compile or language service (not sure which) to extract the prop types. I was able to make a Babel plugin to generate the docgen required by Storybook For a non-Babel version, I think we'll need it written as a plugin for TypeScript. You should be able to pull what you need from Styleguidist's library. |
@strothj |
@ainalain I was proposing that a TypeScript plugin could be written to perform the code transform but after investigation it looks like that won’t be possible. TypeScript plugins don’t allow for code transforms. They only provide information to code editors for things like linting. I think writing a Webpack plugin or loader would be the route to take. |
So I hacked together a Webpack plugin for this: It is very rough but it was done in a day. Will need testing. |
@strothj Thank you very much! |
@ainalain No problem. I've looked into the issue. |
I have tried it and it works! super nice job! |
I'm going to close this since this seems like a good enough workaround. If someone can volunteer to help document this, it'd be greatly appreciated. New issue created for TS documentation linked. Thanks! |
If you use Babel with Typescript, I also recommend using this https://www.npmjs.com/package/babel-plugin-typescript-to-proptypes |
You can also use a preset Here is an example of how to set up a project with CRA + Typescript + Storybook Docs |
Is there a way to use Typescript to set up the props table instead of just using propTypes?
Either a hook which allows a parser (like react-styleguidist does with https://github.com/styleguidist/react-docgen-typescript) or a way to let you pass your own propTypes in so you can do it in user-land?
The text was updated successfully, but these errors were encountered: