Flowtype 在 module.hot.accept 上抛出错误
Flowtype throws an error on module.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;
};
};
我正在尝试使用 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;
};
};