我正在尝试使用TypeScript的https://github.com/arnaudbenard/redux-mock-store . 我还安装了 @types/redux-mock-store
,它有 export default createStore
.
我尝试使用导入:
import createStore from 'redux-mock-store';
import * as createStore from 'redux-mock-store';
TypeScript没有显示第一次导入的任何错误,但是当我实际运行代码时它不起作用,因为我得到 redux_mock_store1.default
不是一个函数 .
当我实际运行我的测试时,第二次尝试正常工作,但TypeScript抱怨"Cannot invoke an expression whose type lacks a call signature"说 @types/redux-mock-store
的默认导出没有兼容的索引签名 .
如何正确导入或使用模块,以便TypeScript不报告任何错误?
1 回答
似乎最新版本的
redux-mock-store
引入了一个突破性的变化,打破了库和相关的打字 . 请参阅Github上的问题 . 您可以恢复到上一个工作版本: