-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
Fix public API errors #778
Conversation
Thank you for your contribution. It seems to me that your changes fix the "problem" but also introduce new bugs. Does every |
Can you add a failing test to this PR, please? |
|
Thank you! Pushed a fix. I'll be honest, I still don't know how to work around the recursion issue, so this is pure brute-force, but it seems to work. Any potential problems? |
I think you fixed it for exactly one layer, but if we nest multiple |
The only and probably simplest way to solve this problem is to define the rule that // With question mark
v.object({ key: v.optional(v.lazy(() => v.string())) }); // { key?: string | undefined }
// Without question mark
v.object({ key: v.lazy(() => v.optional(v.string())) }); // { key: string | undefined } |
This would introduce a breaking change, but since we are still v0, this is ok. I like that this rule simplifies the implementation and makes the library usable for more users. But I don't know if there are any major drawbacks yet. |
Tried every possible hack that I could come up with, no luck. Can't dedicate more time to this, sorry. How about this:
I wouldn't change the API, doesn't feel right to remove something that ultimately works. |
Don't worry about it. I appreciate every contribution! So thank you for the time you have already invested in Valibot. 🙏
I see what you mean, but someone could also argue why there is a question mark when I think that Valibot could become a big and important project in the long run. Therefore, it would be nice to solve the TS error problem and introduce clear rules for such behavior. |
Thank you for caring 😉 Re the API change - what you say makes sense to me, but I think I shouldn't participate in this decision, as I haven't even used |
Another thing you could try is to install Valibot via JSR, as it should ship our source code including the comments: https://jsr.io/@valibot/valibot |
I fixed the TS errors. Thanks for your cooperation! |
Great, thanks! 👍 |
Fix #776
Fix #659
The
getDotPath
test seems alright, but I'm not sure if thelazy
one actually hits the changes, it's a lot of layers to unravel. Can you investigate, please? Also, what's the reason these types were recursive in the first place? Don't mean to pull a Chesterton’s Fence here.