Type issue with persist #2709
Answered
by
dbritto-dev
aaronfulkerson
asked this question in
Bug report
-
Bug DescriptionThe following code produces type errors in VSCode: It looks like this was fixed at one point in time by @dbritto-dev but may have regressed. I'm on 4.5.5. Reproduction Linkhttps://stackblitz.com/edit/vitejs-vite-aryc3n?file=src%2Fstore.ts |
Beta Was this translation helpful? Give feedback.
Answered by
dbritto-dev
Aug 27, 2024
Replies: 1 comment 1 reply
-
import { create } from "zustand";
import { devtools, persist } from "zustand/middleware";
type State = {
sourceRole: { id: number; sourceName: string; sourceRole: string } | null;
};
type Actions = {
setSourceRole: (sourceRole: State["sourceRole"]) => void;
};
export const useSidebarStore = create<State & Actions>()(
devtools(
persist(
(set) => ({
sourceRole: null,
setSourceRole: (sourceRole) => set(() => ({ sourceRole })),
}),
{ name: "sidebar-store" }
)
)
);@aaronfulkerson on ts should be |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
aaronfulkerson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@aaronfulkerson on ts should be
create<T>()(...)orcreateStore<T>()(...)