FlowType在模块上丢弃了一个错误.hot.Accept



我正在尝试使用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;
  };
};

相关内容

最新更新