-
Notifications
You must be signed in to change notification settings - Fork 1
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
Typescript support - Doesn't catch type issues like vanilla valtio proxy #4
Comments
Sorry for the delay - I published a patch to hopefully fix this (0.7.5). Just FYI: This package is still pretty new and in development and it doesn't have many tests in place to verify everything working correctly. Feel free to play around with it and report anything you find (much appreciated!), however it might be a bit early to use in any important projects. |
Thanks! I'll take a look at it. Yeah, this was for a small CMS plugin to do some basic cropping and metadata collection for images and thought it would be interesting to try separating the state and data validation from the UI component, so no worries. |
Hope it works! Let me know if you run into issues. |
Just getting back to thinking about this lib again - and something occurred to me about this issue...there's no reason we can't use z.infer to grab the type defs directly from zod object passed into schema. Basically do what you're doing in your type definitions file. There's no reason to make the lib user do this and make them pass a type. I'll make an issue for this. |
Maybe I'm missing something, but it seems like this doesn't support typescript at the moment? I've used valtio before and was looking for something to help with data validation, but I feel like this now misses out on catching incompatible types. It seems I can't type the proxy like with valtio.
./types with original typescript type and zod schema/inferred type
Example valtio-zod vs valtio store setup with initial data (invalid base64 value)
If trying to use the same typing of proxy, it isn't supported like with valtio.
The text was updated successfully, but these errors were encountered: