Type problem with persist #2176
-
SummaryCode I've written for 4.4.4 which is working very fine, gave typescript error on 4.4.5 argument of type 'StateCreator<useCartType, [], [["zustand/persist", useCartType]]>' is not assignable to parameter of type 'StateCreator<useCartType, [], [never, unknown][]>'. Type 'StateCreator<useCartType, [], [["zustand/persist", useCartType]]>' is not assignable to type '{ $$storeMutators?: [never, unknown][] | undefined; }'. Types of property '$$storeMutators' are incompatible. Type '[["zustand/persist", useCartType]] | undefined' is not assignable to type '[never, unknown][] | undefined'. Type '[["zustand/persist", useCartType]]' is not assignable to type '[never, unknown][]'. Type '["zustand/persist", useCartType]' is not assignable to type '[never, unknown]'. Type at position 0 in source is not compatible with type at position 0 in target. Type 'string' is not assignable to type 'never'. Link to reproductionhttps://github.com/nerkn/ecommerce-Frontend/blob/main/src/hooks/useCart.ts Check List
Please include a minimal reproduction.
Please check this if you're filing an issue regarding TypeScript.
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 9 replies
-
Can concur, experiencing the same issue with using the |
Beta Was this translation helpful? Give feedback.
-
I was about to submit this on Tuesday but couldn't reproduce it. Since wednesday was holiday, I just got around to it. What a coincidence that you beat me by 39 minutes. Here is my reproduction: It only happens with |
Beta Was this translation helpful? Give feedback.
-
I have the same issue |
Beta Was this translation helpful? Give feedback.
-
@nerkn @jwindhager @alexanderhorner @eisa-rezaei here's the fix -> #2170 you can show your love there hehe. BTW, if you can help us test out the changes using the local instructions would be good so @dai-shi can merge it as soon as possible |
Beta Was this translation helpful? Give feedback.
-
I have the same issue on zustand 4.4.7 |
Beta Was this translation helpful? Give feedback.
-
i have similar error Argument of type '{ (nextStateOrUpdater: Store | Partial<Store> | ((state: WritableDraft<Store>) => void), shouldReplace?: false | undefined, action?: Action | undefined): void; (nextStateOrUpdater: Store | ((state: WritableDraft<...>) => void), shouldReplace: true, action?: Action | undefined): void; }' is not assignable to parameter of type '{ (nextStateOrUpdater: CartSlice | Partial<CartSlice> | ((state: WritableDraft<CartSlice>) => void), shouldReplace?: false | undefined, action?: Action | undefined): void; (nextStateOrUpdater: CartSlice | ((state: WritableDraft<...>) => void), shouldReplace: true, action?: Action | undefined): void; }'.
Types of parameters 'shouldReplace' and 'shouldReplace' are incompatible.
Type 'true' is not assignable to type 'false'.ts(2345) my store : const useStoreBase = create<Store>()(
devtools(
persist(
subscribeWithSelector(
immer((...a) => ({
...createAuthSlice(...a),
...createCartSlice(...a),
...createModalSlice(...a),
...createSidebarSlice(...a),
}))
),
{
name: "store",
storage: createJSONStorage(() => AsyncStorage),
}
)
)
);
//? Auto generated selectors for the store using 'auto-zustand-selectors-hook'
//* Usage : useStore.use.selectorName()
export const useStore = createSelectorFunctions(useStoreBase) as typeof useStoreBase & ZustandFuncSelectors<Store>;
//? Setup the devtools using 'simple-zustand-devtools'
//* You can use Redux Devtools Extension as well , with the built in 'zustand/middleware'
if (process.env.NODE_ENV === "development" || __DEV__) {
mountStoreDevtool("compos-resto-store", useStore);
} |
Beta Was this translation helpful? Give feedback.
@nerkn @jwindhager @alexanderhorner @eisa-rezaei here's the fix -> #2170 you can show your love there hehe. BTW, if you can help us test out the changes using the local instructions would be good so @dai-shi can merge it as soon as possible