redux-persist icon indicating copy to clipboard operation
redux-persist copied to clipboard

Typescript stateReconciler error

Open arminhupka opened this issue 2 years ago • 4 comments

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

arminhupka avatar Mar 03 '22 09:03 arminhupka

I have the same issue. Any news?

C3ntraX avatar Mar 15 '22 08:03 C3ntraX

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

PiotrKujawa avatar Mar 30 '22 14:03 PiotrKujawa

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

Correct:

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

Brenndoerfer avatar Jun 13 '22 06:06 Brenndoerfer

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

Vinayak-Soni avatar Dec 23 '23 18:12 Vinayak-Soni