mutative
mutative copied to clipboard
TS4058 Return type of exported function has or is using name DraftedObject from external module
zustand with mutative
I don't know how to workaround this, mutative only export Draft type, the DraftedObject is internal type. using TS 5.9.2, WebStorm
I will try to reproduce this TS type issue later.
@wenerme , I'm not sure if the mutative() you're referring to is the one from zustand-mutative. In any case, it works fine with TypeScript v5.9.2.
import { create } from "zustand";
import { mutative } from "zustand-mutative";
type State = {
count: number;
};
type Actions = {
increment: (qty: number) => void;
decrement: (qty: number) => void;
};
export const useCountStore = create<State & Actions>()(
mutative((set) => ({
count: 0,
increment: (qty: number) =>
set((state) => {
state.count += qty;
}),
decrement: (qty: number) =>
set((state) => {
state.count -= qty;
}),
}))
);
thanks, yes, from zustand-mutative, I'll try reproduce with a minimal repo.