Typescript + Slices = trouble #2503
-
SummaryLots of errors trying to implement slices with the code from docs, i.e the slices pattern found here: Link to reproductionhttps://docs.pmnd.rs/zustand/guides/typescript 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: 7 comments
-
Type 'BearSlice' does not satisfy the constraint 'StoreApi<BearSlice & FishSlice>'. Type '{ bears: number; addBear: () => any; eatFish: () => any; }' is not assignable to type 'BearSlice & FishSlice'. Module '"zustand"' has no exported member 'create'. Did you mean to use 'import create from "zustand"' instead?ts(2614) |
Beta Was this translation helpful? Give feedback.
-
@buzzdead btw, now there's a package called zustand-slices that helps you with that. Give it a try a let us know |
Beta Was this translation helpful? Give feedback.
-
That seemed to take away all the errors i had, just installing the package. |
Beta Was this translation helpful? Give feedback.
-
We know that typing slices is a bit tricky. BTW, we are working on revamping docs. |
Beta Was this translation helpful? Give feedback.
-
Worked like a charm after installing the package. Thanks for the lightning fast response. Anyway, Ill continue with sustand. |
Beta Was this translation helpful? Give feedback.
-
It's not necessary but is an option now |
Beta Was this translation helpful? Give feedback.
-
Anyway, next time make sure you share a typescript playground link when you face typescript issues or try to format your code so would be easy to read |
Beta Was this translation helpful? Give feedback.
@buzzdead btw, now there's a package called zustand-slices that helps you with that. Give it a try a let us know