redux-persist
redux-persist copied to clipboard
Typescript stateReconciler error
I have next.js project where I using this library but I have type issue during using stateReconciler: hardSet
My problem looks like this
TS2345: Argument of type 'Reducer<CombinedState<{ user: any; cart: any; player: playerInitialState; }>, AnyAction | playerAction>' is not assignable to parameter of type 'Reducer<unknown, AnyAction | playerAction>'. Types of parameters 'state' and 'state' are incompatible. Type 'unknown' is not assignable to type 'CombinedState<{ user: any; cart: any; player: playerInitialState; }> | undefined'. Type 'unknown' is not assignable to type 'CombinedState<{ user: any; cart: any; player: playerInitialState; }>'.

I have the same issue. Any news?
Try this:
const persistedReducer = persistReducer<ReturnType<typeof reducers>>(persistConfig, reducers);
Thanks @PiotrKujawa , but you have a typo (duplicate persistReducer
)
Correct:
export const persistedReducer = persistReducer<ReturnType<typeof rootReducer>>(
persistConfig,
rootReducer
);
still working export const persistedReducer = persistReducer<ReturnType<typeof rootReducer>>( persistConfig, rootReducer );