Flowtype throws an error on module.hot.accept

I am trying to check the code using the flowtype type:

export default function configureStore(initialState: initialStateType) {
    /* ... */
    if (module && module.hot) {
        module.hot.accept('../reducers', () => {
            const nextRootReducer = require('../reducers');
            store.replaceReducer(nextRootReducer);
        });
    }
    /* ... */
}

And I get this error message:

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

How can i fix this?

Thank!

+4
source share
1 answer

You need to add the following declaration to the file specified in the .flowconfig [libs] section. You can find more information on adding library definition files here: https://flow.org/en/docs/libdefs/

declare var module : {
  hot : {
    accept(path:string, callback:() => void): void;
  };
};
+5
source

Source: https://habr.com/ru/post/1676339/


All Articles