eatdrinkhealthy / edh-app

The Eat Drink Healthy web (and tentatively mobile / cordova) app created with Meteor and React.
0 stars 0 forks source link

Flowtype question: how to properly use react-redux MapStateToProps libdef declaration #36

Closed stevenjmarsh closed 7 years ago

stevenjmarsh commented 7 years ago

(flowtype/require-return-type) warning

In FilterContainer, there is the straight forward use of mapStateToProps and connect().

To properly define its return type, the locally defined mapStateToProps function seems like it could use the MapStateToProps type in the react-redux libdef, but I am not sure of the syntax (or more specifically, not sure if that declaration is supposed to be used / exported).

stevenjmarsh commented 7 years ago

painful, but figured it out. part of the issue was, verbose error message from flowtype, listing many different solutions to the error because connect() is polymorphic.

after reading the error message more carefully, noticed the mapToProps functions simply needed to have return annotations. without them, null / void was inferred, causing the type error. Once I annotated the return type, the errors cleared.