question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[react-redux] libdef incompatible with flow v0.85

See original GitHub issue

The todos-flow example just works with flow v0.78 and the current flow-typed react-redux types, but after upgrading to flow v0.85 there are a lot of flow errors I am not able to fix.

Full repo here and full error log here.

> todos-flow@0.0.1 flow 
> flow

Error ------------------------------------------------------------------------------- src/containers/FilterLink.js:29:19

Missing type annotation for `CP`. `CP` is a type parameter declared in function type [1] and was implicitly instantiated
at call of `connect` [2].

   src/containers/FilterLink.js:29:19
                          v-------
    29| const connector = connect(
    30|   mapStateToProps,
    31|   mapDispatchToProps
    32| );
        ^ [2]

References:
   flow-typed/npm/react-redux_v5.x.x.js:133:34
                                         v
   133|   declare export function connect<
   134|     Com: ComponentType<*>,
   135|     A,
   136|     S: Object,
   137|     DP: Object,
   138|     SP: Object,
   139|     RSP: Object,
   140|     RDP: Object,
   141|     CP: $Diff<$Diff<ElementConfig<Com>, RSP>, RDP>,
   142|     ST: $Subtype<{[_: $Keys<Com>]: any}>
   143|     >(
   144|     mapStateToProps: MapStateToProps<S, SP, RSP>,
   145|     mapDispatchToProps: MapDispatchToProps<A, DP, RDP>
   146|   ): (component: Com) => ComponentType<CP & SP & DP> & $Shape<ST>;
          --------------------------------------------------------------^ [1]


Error ------------------------------------------------------------------------------- src/containers/FilterLink.js:29:19

Missing type annotation for `DP`. `DP` is a type parameter declared in function type [1] and was implicitly instantiated
at call of `connect` [2].

   src/containers/FilterLink.js:29:19
                          v-------
    29| const connector = connect(
    30|   mapStateToProps,
    31|   mapDispatchToProps
    32| );
        ^ [2]

References:
   flow-typed/npm/react-redux_v5.x.x.js:133:34
                                         v
   133|   declare export function connect<
   134|     Com: ComponentType<*>,
   135|     A,
   136|     S: Object,
   137|     DP: Object,
   138|     SP: Object,
   139|     RSP: Object,
   140|     RDP: Object,
   141|     CP: $Diff<$Diff<ElementConfig<Com>, RSP>, RDP>,
   142|     ST: $Subtype<{[_: $Keys<Com>]: any}>
   143|     >(
   144|     mapStateToProps: MapStateToProps<S, SP, RSP>,
   145|     mapDispatchToProps: MapDispatchToProps<A, DP, RDP>
   146|   ): (component: Com) => ComponentType<CP & SP & DP> & $Shape<ST>;
          --------------------------------------------------------------^ [1]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

9reactions
peter-leonovcommented, Dec 15, 2018

@zanettin @villesau here is a promised PR #3012 😅

I’d say the adapted typings are production ready now. They support options and mergeProps arguments to connect() with proper connection to the component props and mapStateToProps, own props, etc. Most of the type arguments can be requested to be inferred with the new _ type placeholder.

6reactions
jbrown215commented, Dec 3, 2018

I think @peter-leonov did a really good job with https://gist.github.com/peter-leonov/e1fac25b6ade9b28c03c213e8a9d7121.

With these types, you should have OwnProps, StateProps, and DispatchProps (OP, SP, and DP) all be exact object types. In your component that combines all three of these types, use:

type Props = {| ...OwnProps, ...StateProps, ...DispatchProps |}

It’s important that you don’t use intersection with exact objects, since that will produce an empty type.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Errors encountered upgrading Flow v0.85, and how we solved ...
Issue: [react-redux] libdef incompatible with flow v0.85 #2946 · Tweet: It's so hard to make flow happily get past 0.85 with our codebase ......
Read more >
reactjs - Flow error "props is incompatible with empty" when ...
I have a component that is wrapped in a react-redux "connect". All the props of the component ...
Read more >
Adventures in Static Typing: React, Redux, Flow, Oh My
Adding end-to-end static typing to a React/Redux app is a lot of work — you'll run into issues with Flow, third-party annotations, ...
Read more >
.flowconfig [options] | Flow
How to configure Flow's various options. ... The default value for autoimports is true as of Flow v0.155.0. babel_loose_array_spread (boolean).
Read more >

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found