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: Move to react-docgen for typescript prop tables #9837

Closed
5 of 7 tasks
shilman opened this issue Feb 13, 2020 · 3 comments
Closed
5 of 7 tasks

Addon-docs: Move to react-docgen for typescript prop tables #9837

shilman opened this issue Feb 13, 2020 · 3 comments

Comments

@shilman
Copy link
Member

shilman commented Feb 13, 2020

We currently use react-docgen for JS prop tables and react-typescript-docgen-loader (RDTL) for TS prop tables. Now that react-docgen supports Typescript natively, let's simplify our lives and our users' configurations by moving to react-docgen for all react prop table generation.

@maniax89
Copy link
Contributor

@shilman was taking a look at the reasoning behind this issue and one of the issues I was trying to get around was this statement in react-docgen for typescript:

https://github.com/reactjs/react-docgen#flow-and-typescript-support

Note: react-docgen will not be able to grab the type definition if the type is imported or declared in a different file.

This is noted in strothj/react-docgen-typescript-loader#80 (comment)

This loader unfortunately does not automatically locate your project's tsconfig.json file (would be a great enhancement if a pull request is made).

If its path isn't specified, the underlying library react-docgen-typescript will fallback to creating a new TypeScript project for each file (I believe), which unfortunately does not resolve types external to the file being checked.

I've updated the documentation and updated the example project to show its usage:

will react-docgen support loading types external to the file being checked eventually? or is this use-case dropped in the CRA preset (storybookjs/presets#103) without a workaround?

@shilman
Copy link
Member Author

shilman commented Mar 11, 2020

@maniax89 please upvote this reactjs/react-docgen#352

There's currently no workaround for this issue. The rationale for the move is that, despite this limitation:

  1. there are LOTS of bugs in react-docgen-typescript-loader that are already fixed in react-docgen
  2. going "all in" on one library simplifies support and maintenance on the storybook side
  3. react-docgen seems to have critical mass, react-styleguidist also adopted it in 110 https://github.com/styleguidist/react-styleguidist/releases/tag/v11.0.0
  4. you can still use the old configuration if needed (for now)

@shilman
Copy link
Member Author

shilman commented May 22, 2020

OK gang. We've reversed course on this:

👉👉👉 react-docgen-typescript is now the default in SB6.

I documented this out in detail for anybody who cares, and will be updating the rest of the docs shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Hotlist
6.0 priority features
Development

No branches or pull requests

2 participants