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.
* feat(types): better middleware support * some more trial * some more trial * Revert "some more trial" This reverts commit c54bf7c. * some more trial * some more trial * some more trial * some more trial * Revert "some more trial" This reverts commit 3aef9e2. * some more trial * Revert "some more trial" This reverts commit fce0cb4. * some more trial * some more trial * some more trial * some more trial * add redux middleware type test * fix with type alias * add devtools and redux combination test * combine to support named set * remove duplicated types
…mndrs#617) * chore(tests): add a use case combining many middleware * simplify middleware types and allow explicit typing reverting some of pmndrs#601 * fix context tests * prettier * refine middleware type test for more coverage and readability
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?)