rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.91k stars 863 forks source link

Typescript stateReconciler error #1368

Open arminhupka opened 2 years ago

arminhupka commented 2 years ago

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; }>'.
image
C3ntraX commented 2 years ago

I have the same issue. Any news?

PiotrKujawa commented 2 years ago

Try this: const persistedReducer = persistReducer<ReturnType<typeof reducers>>(persistConfig, reducers);

Brenndoerfer commented 2 years ago

Thanks @PiotrKujawa , but you have a typo (duplicate persistReducer)

Correct:

export const persistedReducer = persistReducer<ReturnType<typeof rootReducer>>(
  persistConfig,
  rootReducer
);
Vinayak-Soni commented 7 months ago

still working export const persistedReducer = persistReducer<ReturnType>( persistConfig, rootReducer );