-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Extract proptypes in Typescript (interfaces) #77
Comments
Are you asking for the To get the type of what a component expects to be passed in (i.e. "external" or "apparent" props), you can use: import SomeComponent from 'external-library'
type InternalProps = React.ComponentProps<typeof SomeComponent>
type ApparentProps = JSX.LibraryManagedAttributes<typeof SomeComponent, InternalProps> |
I was able to retrieve the props passed down to a component, but I wanted to get the whole interface, even the props which aren't passed down. But I'll look into the things @sw-yx mentioned this week and see if it can solve my problem. I'll also look into the code example you gave me, thank you! |
How can I extract the proptypes (the interface) of a component in Typescript? I Know I can access the component and get the props easily, but I want to get the types, so that I can easily generate a nice show-case for my lib components.
The text was updated successfully, but these errors were encountered: