let persistor: Persistor = {
..._pStore,
purge: () => {
The problem here is that Persistor defines dispatch, getState and subscribe as read-only, while _pStore imports the flow-types of these 3 properties from 'redux'. Flow-typed defines the same properties as writable for 'redux' library.
This causes flow to throw 3 erros:
$ flow
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ node_modules/redux-persist/lib/persistStore.js.flow:94:30
Property dispatch is not writable.
Property getState is not writable.
Property subscribe is not writable.
More detail
In persistStore.js.flow, _pStore is defined using createStore flow-typed definition imported from 'redux
import { createStore } from 'redux'
let _pStore = createStore(persistorReducer, initialState, options ? options.enhancer : undefined)
On redux_v3.x.x.js, createStore returns a Store type where dispatch, getState and subscribe are writable:
declare export function createStore<S, A, D>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>;
declare export type Store<S, A, D = Dispatch<A>> = {
// rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages)
dispatch: D;
getState(): S;
subscribe(listener: () => void): () => void;
replaceReducer(nextReducer: Reducer<S, A>): void
};
However, the flow type "Persistor" on persistStore.js is read only:
In node_modules/redux-persist/lib/persistStore.js.flow:94:30, persistor is defined as
The problem here is that Persistor defines dispatch, getState and subscribe as read-only, while _pStore imports the flow-types of these 3 properties from 'redux'. Flow-typed defines the same properties as writable for 'redux' library.
This causes flow to throw 3 erros: $ flow Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ node_modules/redux-persist/lib/persistStore.js.flow:94:30
Property dispatch is not writable. Property getState is not writable. Property subscribe is not writable.
More detail
In persistStore.js.flow, _pStore is defined using createStore flow-typed definition imported from 'redux
On redux_v3.x.x.js, createStore returns a Store type where dispatch, getState and subscribe are writable:
However, the flow type "Persistor" on persistStore.js is read only: