0
votes

I am trying to use https://github.com/arnaudbenard/redux-mock-store with TypeScript. I have also installed @types/redux-mock-store which has export default createStore.

I have tried importing using:

import createStore from 'redux-mock-store';

import * as createStore from 'redux-mock-store';

TypeScript does not show any errors for the first import, but when I actually run the code it doesn't work since I get redux_mock_store1.default is not a function.

The second attempt works properly when I actually run my tests, but TypeScript complains "Cannot invoke an expression whose type lacks a call signature" saying that the default export of @types/redux-mock-store has no compatible index signatures.

How can I properly import or use module so that TypeScript doesn't report any errors?

1

1 Answers

2
votes

It seems like the latest version of redux-mock-store introduced a breaking change that breaks both the library and the associated typings. See the issue on Github. You can just revert to the last working version:

yarn add --dev [email protected]