-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
React router flow@0.53.x fixes #1214
React router flow@0.53.x fixes #1214
Conversation
Our type signature should not assume that additional keys may be present in this object.
Thanks! Manually editing my installed react-router-dom_v4.x.x.js with the patch from this PR fixed this problem for me:
|
intersection of inexact object types behaves much like spreading, but when both objects are exact, the intersection type becomes an empty set. See: facebook/flow#2626
b898a03
to
a807d13
Compare
a807d13
to
18e9122
Compare
@ajhyndman I've started seeing errors with code like this (note this is just an example otherwise it would be a pretty useless app):
It seems like this might be related to this PR...am I wrong? If so happy to open a separate issue |
nevermind my mistake after all, this fix just exposed me misusing the API..thanks! |
@ajhyndman I'm a bit confused, what needs to be done in a component to avoid issues on |
@chrisdrackett My intent with this PR was just to improve the typedefs so they work with a wider range of use cases without trouble. This PR did end up getting merged. Are you running into some specific issue still? P.S. I like the avatar choice. |
@aaronjensen I'm just having trouble getting export default withRouter(MyComponent) flow complains:
|
@chrisdrackett It sounds like flow doesn't think |
I'm having an issue with these changes while using two HOCs. I've made a reduced example of the behavior. I'm trying to use Material UI with
and then Flow says:
If I change the declaration to look like: declare export function withRouter<P>(
- Component: React$ComponentType<{| ...ContextRouter, ...P |}>
+ Component: React$ComponentType<{ ...ContextRouter, ...P }>
): React$ComponentType<P>; then it passes, but I'm not sure this is the right solution. Any ideas what's going wrong here? |
@zachwolf What do your flow types for |
@ajhyndman thanks for the response. I think... it'd be:
Taken from mui |
@zachwolf Aha! It looks like, internally, they are depending on another project for the https://github.com/digiaonline/react-flow-types/blob/develop/index.js.flow#L21-L24 And in this definition, they are still using intersection types, which won't handle exact objects, for the reasons I tried to outline above. I think you might be better served filing an issue with This issue looks related: |
@ajhyndman awesome response, thank you! I've opened an issue. |
These are a couple minor bugfixes to the react-router_v4 and react-router-dom_v4 typedefs.
Currently the props shape for the HOC
withRouter
constructs its internal prop shape with type intersection of inexact object. This works, but only if the inner component's props signature is an inexact object.We can improve on this, by using an exact object type for
ContextRouter
and using type spread notation.See also:
facebook/flow#2626