-
-
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
Improve Typescript types and generics #22
Conversation
Looks good to me, we need these types as well at work, duplicated them for now. @JeremyRH how do you feel? You still wanted to remove the internal types, like StateSelector, is this correct? |
The reason for not wanting to expose all the types is mostly for type names. If we change a name, it's a breaking change. I do see the value for not duplicating types though so I'm thinking we should expose all the types. I'll test out these changes today and try to get this merged. Thanks @Luxizzle! |
When using "zustand" in one of our projects, I had defined the types UseStore and StoreApi in globals.d.ts myself. Now I came across this pull request. If I now compile the project with Luxizzle's solution directly with tsc, I get some compiler errors. These can also be reproduced in this repo when compiling the file test.tsx. For this reason, I have adapted the definitions in my own branch and adapted the configuration so that it can be compiled directly with tsc (yarn build:tsc). You can have a look at it if you like: Please correct me if I am wrong. |
@dm385 You're right, the tests were failing with Luxizzle's changes. I asked them to create a PR so we could work on fixing the issues together. I have a version of their changes working without changing the tests now. And thank you for the fixes on your fork. I'll see if there's anything there that I can add to this. |
I updated everything with the proposed changes you gave. Thanks for all the explanations by the way, they really helped! |
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.
Thanks!
Fixes #21
Exports a few types for usage outside of the module and adds default types for generics.