-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Making coerce
to be a type argument
#1793
Conversation
✅ Deploy Preview for guileless-rolypoly-866f8a ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
The |
Should be fixed after merging #1794 |
b1c2efd
to
f64c0b2
Compare
@JacobWeisenburger || @colinhacks , please review |
Unfortunately, I don't think I have enough experience to approve this. Perhaps @colinhacks or @scotttrinh would be able to help. |
Ok. I updated the description for the clarity. |
@colinhacks || @scotttrinh , please review |
Why not create a new Also, I don't think |
Discussed this under the original issue: #1760 (comment) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Fixes #1760
This PR makes the schema types, that support
coerce
feature, to have the correct type of the input schema if this feature is enabled.Thus,
z.coerce.number()
will have the type compatible toZodType<number, ZodNumberDef, any>
.Third type argument stands for input type, which in case of
coerce
accepts anything.Therefore, taking
z.input<>
on such schema will returnany
.The behavior of schemas and methods without
coerce
feature, of having that feature disabled, remains the same.Thanks to the default values of the new type argument, this change is backward compatible.