Skip to content

Typescript support for defining component Interface through React interface #387

Open

Description

@nxnzesrc

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!

Activity

  1. nxnzesrc commented on Sep 16, 2019

    @nxnzesrc
    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.

  2. 7rulnik commented on Sep 16, 2019

    @7rulnik
  3. danez commented on Dec 11, 2019

    @danez
    Collaborator

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

  4. josias-r commented on Jan 14, 2020

    @josias-r

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

  5. danez commented on Jan 18, 2020

    @danez
    Collaborator

    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.

  6. Dashue commented on Mar 11, 2020

    @Dashue

    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 :)

  7. Winner95 commented on Mar 23, 2020

    @Winner95

    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.

  8. smeevil commented on May 30, 2020

    @smeevil

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

  9. DeviousCardi commented on Nov 21, 2026

    @DeviousCardi

    Fix for this is up in #1208 — props defined only via React.FC<Props> (interface, type alias, or inline literal) are now resolved, including Flow-parsed sources, React.memo<Props>(...) generics, and named functions assigned to an annotated variable (const C: React.FC<Props> = Inner).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions