Type problem with persist
nerkn opened this issue · comments
Summary
Code 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 reproduction
https://github.com/nerkn/ecommerce-Frontend/blob/main/src/hooks/useCart.ts
Check List
- I've already opened a discussion before opening this issue, or already discussed in other media.
comment of muammed
Please include a minimal reproduction.
- I've added a link to a typescript playground or codesandbox with a minimal reproduction.
Please check this if you're filing an issue regarding TypeScript.
- I've read the typescript guide, in particular that
create
is to be used ascreate<T>()(...)
and notcreate<T>(...)
.
Can concur, experiencing the same issue with using the immer
middleware (immer@10.0.3) in v4.4.5. No problem with v4.4.4.
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:
https://codesandbox.io/p/sandbox/vibrant-bash-prcf7q?file=%2Fsrc%2Fstore.ts%3A21%2C6
It only happens with "moduleResolution": "bundler",
in tsconfig.
I have the same issue