zustand-store-addons
zustand-store-addons copied to clipboard
Type error when using immer middleware
Example code:
import create from "zustand-store-addons";
interface Store {
value: number;
increase: () => void;
}
export const useStore = create<Store>(
(set, get) => ({
value: 0,
increase: () => {
set(state => { // Report error at this line
^^^^^^^^^^
state.value++;
});
},
}),
{ middleware: [immer] },
);
Error info:
Argument of type '(state: Store) => void' is not assignable to parameter of type 'PartialState<Store>'.
Type '(state: Store) => void' is not assignable to type '(state: Store) => Partial<Store>'.
Type 'void' is not assignable to type 'Partial<Store>'.ts(2345)
It looks like the original action type is not compatible with the action type after using Immer middleware.
@GoodbyeNJN is this still an issue? @Diablow is there anything we can help with or provide to get this resolved?