-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(types): better middleware support #601
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 69a078b:
|
Size Change: 0 B Total Size: 9.88 kB ℹ️ View Unchanged
|
src/index.ts
Outdated
setState: CustomStoreApi['setState'] | ||
getState: CustomStoreApi['getState'] | ||
subscribe: CustomStoreApi['subscribe'] | ||
destroy: CustomStoreApi['destroy'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not wrong, these four fields are already in CustomStoreApi
, right?
Why not just remove these four lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. At a certain commit, it was interface
which can't be merged with CustomStoreApi
. Now, it's type alias, and we can remove them.
Okay, to be honest, I don't like the tricky typescript typing. middleware is very type unfriendly.
I wouldn't build the API with middleware in this typescript era. (see jotai and valtio.)
That said, we still want to have better TS support in zustand.
Even though this makes the code less maintainable, it's worth it.
(We should add more type tests and middleware behavior tests. Any volunteers?)