fix unwrap for default, arrays of enums, and generally all unwrappables in every order we support #135
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)