Skip to content
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 unwrap for default, arrays of enums, and generally all unwrappables in every order we support #135

Merged
merged 2 commits into from
Sep 8, 2023

Conversation

scamden
Copy link
Collaborator

@scamden scamden commented Aug 4, 2023

I noticed our unwrap types didn't work for .default() even though the runtime code did. I've also seen a bug where z.enum().array() doesn't match either (because we didn't unwrap the enum type of the array element).

The solution to all of this (and a few other possible differences in order) was to make the unwrap recursive. However, the type had a comment mentioning that previously that created a stack overflow.

Turns out this is possible (and seems fast) as long as we limit the depth to the max number of unwraps we allow. Similar to what we did with the type recursion in PropType (but much much simpler here)

cc @brettzallen (for the default problem) @matasar-watershed (cause the enum array problem)

@vercel
Copy link

vercel bot commented Aug 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-ts-form ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 4, 2023 0:49am

@scamden
Copy link
Collaborator Author

scamden commented Aug 7, 2023

@iway1 i'm inclined to merge as this fixes a host of issues, but let me know if you are uncomfortable

@scamden scamden merged commit 205892d into iway1:main Sep 8, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants