Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flowtype throws an error on module.hot.accept

I'm trying to check some code with flowtype:

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

And I'm getting 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?

Thanks!

like image 422
Vakhlov Avatar asked May 04 '17 08:05

Vakhlov


1 Answers

You need to add the following declare to a file that you point to in your .flowconfig's [libs] section. You can find more information about adding library definition files here: https://flow.org/en/docs/libdefs/

declare var module : {
  hot : {
    accept(path:string, callback:() => void): void;
  };
};
like image 89
Lee Vaughn-Ogin Avatar answered Dec 03 '22 03:12

Lee Vaughn-Ogin