我正在尝试检查一些带有flowtype的代码:
export default function configureStore(initialState: initialStateType) {
/* ... */
if (module && module.hot) {
module.hot.accept('../reducers', () => {
const nextRootReducer = require('../reducers');
store.replaceReducer(nextRootReducer);
});
}
/* ... */
}
我收到此错误消息:
src/store/configureStore.js:14
14: module.hot.accept('../reducers', () => {
^ call of method `accept`. Method cannot be called on
14: module.hot.accept('../reducers', () => {
^^^^^^^^^^ property `hot` of unknown type
我怎样才能解决这个问题?
谢谢!
最佳答案
您需要将以下声明添加到您在.flowconfig的[libs]部分中指向的文件中。您可以在此处找到有关添加库定义文件的更多信息:https://flow.org/en/docs/libdefs/
declare var module : {
hot : {
accept(path:string, callback:() => void): void;
};
};