-
Notifications
You must be signed in to change notification settings - Fork 12.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
Extract inferred external Props from a React Component with defaultProps #26704
Comments
You are looking for: type TestProps = JSX.LibraryManagedAttributes<typeof Test, Test["props"]>; which is what the TypeScript compiler is in fact using. |
Would be nice to put that in the React .d.ts file for consistency |
It also would be nice if TypeScript would automatically detect the type of
So we don't have to declare (Sorry, if this should be an issue on its own I will gladly create it) |
@cheeZery I don't understand the example. You have declared that the |
Yeah, exactly, and that's the bug I would like TypeScript to detect :-) Sorry, that I didn't made that clear! At the moment you can set whatever key value pairs you want in |
@cheeZery Yes, please file a new issue as this is unrelated to the current issue. |
Is there any plan to add |
For Functional components use: type MyCompProps = JSX.LibraryManagedAttributes<typeof MyComp, React.ComponentProps<typeof MyComp>> as |
Search Terms
ElementProps, ElementConfig, "component props with defaultProps"
Suggestion
Now that TypeScript infers the external Props API for a Component with
defaultProps
, it would be helpful to add a type that returns the inferred props from a component. Flow accomplishes this with "React.ElementConfig".Use Cases
Examples
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: