Sam Goldman
Oct 30, 2018 · 1 min read

Ville Saukkonen Thanks! And thanks for your thoughtful questions.

Like I wrote in the post, the S, D, and OP type parameters seem to be the only ones that truly appear in input positions. I spent some time working on new typings for the connect function which would only require annotations for those types.

I came up with something fairly simple, but not 100% complete. From reading the react-redux source as well as the various type definitions around, I think the definitions in that playground link do capture the essential complexity of the API.

I think we need to add a few language features to make this 100%. I spent a couple weeks in fact working on this, but ultimately decided to move forward with this change anyway.

When Jordan Brown’s work to support _ in explicit type arguments, it will be more convenient to provide these annotations. You would be able to write something like this:

module.exports = connect<State, Dispatch, OwnProps, _, _>(mapStateToProps, mapDispatchToProps)(MyComponent);

As far as migrating our codebase internally, there are a lot of new errors. We are suppressing them and communicating to individual teams how to best remove the suppressions and provide the necessary annotations. In most cases, adding explicit type arguments to function and constructor calls is the most convenient solution.

    Sam Goldman

    Written by