Propersal: A easier way for middleware typescript design #2903
Replies: 1 comment 1 reply
-
Sure, I wish it would have been easier. There's a chance though. Since v5, we dropped some old TS versions, so there should be some rooms for improvement. Your code snippet looks like basically the same as what we are doing. You may want to try using zustand creator signature We can't always infer types from the bottom, and we need support the explicit state typing use case btw, personally I'm not in favor of explicit state typing and I'm pushing alternative solutions like zustand-slices.
As I understand, zustand api isn't typescript first (= mutation), and this is a challenge for an advanced typescript user. |
Beta Was this translation helpful? Give feedback.
-
The current typescript middleware design is way too complicated for an average typescript user like me, I tried to follow up #710, The takeaway is that we try to propagate though the mutation to top level, and there is a very complicated protocol to force the way we use typescript
In order to achieve the same result, there may be a simpler way
The code is simple enough for a average typescript user to understand, how you guys think about it?
Beta Was this translation helpful? Give feedback.
All reactions