Definitelytyped: Dispatch is no longer an exported member of @types/react-redux

Created on 26 Jun 2018  路  7Comments  路  Source: DefinitelyTyped/DefinitelyTyped

Dispatch no longer appears to be exported

Error Message:

TS2305: Module '"@types/react-redux/index"' has no exported member 'Dispatch'.

Code Sample:

import { connect, Dispatch } from "react-redux";

export function mapDispatchToProps(dispatch: Dispatch<AppActions>): HomeProps {
    return {
        genericProp: () => dispatch(genericActions.Action()),
    };
}

export default connect(mapStateToProps, mapDispatchToProps)(Home);
package.json:
"@types/react-redux" : "^6.0.3",
typescript: ^2.9.2,
  • Authors: @....
    @gaearon, @jimbolla, @ellbee, @timdorr

Most helpful comment

I used the code from https://github.com/Microsoft/TypeScript-React-Starter
import { connect, Dispatch } from 'react-redux';

This is really a breaking change. I understand Dispatch is part of "redux" instead of "react-redux". But should such breaking change happen in a minor version update?

All 7 comments

Dispatch isn't a type of this library. You're looking for the Redux types.

it was in version 6.0.2?
line 37 index.d.ts

@timdorr your comment was not very clear but I interpreted what you meant.
I assume Dispatch has been removed from the react-redux library in the latest version cut 6.0.3,
I will use the Dispatch type on the redux library in the future.

Thanks for your help :)

I used the code from https://github.com/Microsoft/TypeScript-React-Starter
import { connect, Dispatch } from 'react-redux';

This is really a breaking change. I understand Dispatch is part of "redux" instead of "react-redux". But should such breaking change happen in a minor version update?

@shincysl I also learn TypeScript from his code, and I directly import Dispatch from the 'redux'.

What is the best solution?

import { connect } from "react-redux";
import { Dispatch } from "redux";
Was this page helpful?
0 / 5 - 0 ratings