-
-
Notifications
You must be signed in to change notification settings - Fork 19
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 optional error #37
base: main
Are you sure you want to change the base?
Conversation
We need that check though. Checking if the node's name is |
The type that See the following example:
@unknownpgr Given this, your case should NOT be considered an error. Since you can successfully parse an object when the |
@sachinraja Can you confirm this? (A) If that (A) is confirmed, this would also mean the behaviour described by: #59 is actually not an issue and is intended. In my situation (A) is actually exactly what I'm looking for, so it would be great if that's the case. However, I can see why (B) in some situation might be useful too. Firstly: I think it needs to be clearly stated in the README or documentation which of the two it is. Secondly: If there is merit for both, that both should have support. |
@simonkarman Thanks for your explanation. According to your explanation, I mean (A), it is clear that my case is not an error and it is intended. But as you stated later, In my case I need (B). I used this library to implement automatic API generation, something like And if (A) is accepted, I think the generated type of any object schema should be
|
@unknownpgr thanks for pointing that out! The
However, it is important pointing out, as I'm not entirely sure in which ways Zod can handle unknown properties and whether these properties remain on the output of the parse method. Would have to dive deeper into this to see if that functionality would align between zod-to-ts and Zod given that (A) is true. |
I found an error where when using the default() method, a field that should not be optional becomes optional. z.isOptional() seems to indicate whether the input value is optional, not whether the output type is optional.