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

Typescript support for defining component Interface through React interface #387

Open
jonathancopperstone opened this issue Aug 16, 2019 · 8 comments

Comments

@jonathancopperstone
Copy link

jonathancopperstone commented Aug 16, 2019

I'm playing around with the playground and noticed that if you type your component in this way const MyComponent: React.FC<IProps> = .., react-docgen doesn't pick up the interface in IProps.

Screenshot 2019-08-16 at 13 22 06
Screenshot 2019-08-16 at 13 22 36

I'm curious to know if there's a specific reason for this, and if support for this might be on the roadmap.

Thanks!

@jonathancopperstone
Copy link
Author

Any guidance on this please? I'd be happy to take a look and create an MR for this if pointed in the right direction / is it something on your roadmap.

@7rulnik
Copy link

7rulnik commented Sep 16, 2019

@johnnycopperstone I think the problem somewhere in this module https://github.com/reactjs/react-docgen/blob/e05219b08c8b17899be812a521b4985f2b66fae2/src/utils/isStatelessComponent.js

You can debug it with --inspect-brk flag https://nodejs.org/de/docs/guides/debugging-getting-started/

@danez
Copy link
Collaborator

danez commented Dec 11, 2019

The playground parses the code with flow enabled, but not sure if it would work if it gets parsed as typescript.

@josias-r
Copy link

The React.FC<Props>is working for me in the latest version 🤔

@danez
Copy link
Collaborator

danez commented Jan 18, 2020

I just checked again and the problem is only happening when the Props are only defined in the React.FC<Props> and not in the props argument itself.

Will look into this soon.

@Dashue
Copy link

Dashue commented Mar 11, 2020

Coming here from storybook migration guide to 6.0.
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#from-version-53x-to-60x

This is how we define our components so will wait on this to be resolved, rather than re-writing all our components.

Unfortunately I'm not able to help with a fix for the issue.

Thanks in advance to whoever does :)

@Winner95
Copy link

Winner95 commented Mar 23, 2020

I hope it might help as temporary workaround - I made a custom handler for parsing React.FC < Props >, which points at existing Props at UI-component.

@smeevil
Copy link

smeevil commented May 30, 2020

Keeping my eye on this @danez , 6.0 is looking great so far :)

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

7 participants