-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
ExternalRelates to another program, environment, or user action which we cannot control.Relates to another program, environment, or user action which we cannot control.
Description
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
- Extending React components and re-using their prop types without re-writing them.
Examples
class Test extends React.Component<{ foo: string, bar: number }> {
static defaultProps = {
foo: 'baz',
}
render() {
...
}
}
type TestProps = React.ElementConfig<Test>; // { foo?: string, bar: number }
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript / JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. new expression-level syntax)
brieb, vkrol and stanimirgeorgiev
Metadata
Metadata
Assignees
Labels
ExternalRelates to another program, environment, or user action which we cannot control.Relates to another program, environment, or user action which we cannot control.