-
Notifications
You must be signed in to change notification settings - Fork 11
__nullable__
vs Type.Optional
#33
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
Comments
Because prisma in some scenarios allows null OR undefined as types where optional only allows for undefined/is reflected as undefined in TS types |
Regarding the second aspect: This roots from calling the options generator function which injects this based on the global setting. Since this causes no harm its just there and I saved myself the time and complexity of implemention logic to check the necessity |
That's fair. For my use case, I'll just transform the output (or remap For prismabox/src/generators/primitiveField.ts Lines 30 to 31 in 7a06124
E.g. something like this?: let optionsObject = JSON.parse(options)
delete optionsObject.additionalProperties
options = JSON.stringify(optionsObject) I think it might be a real bug because it's included for json columns - so |
@m1212e would you be open to a PR with my suggested change? |
True, I think this would work, thats perfectly fine to do imo. I'd be happy to review a PR! |
Here you go: |
It occurs to me that to properly close this issue, we should probably add some documentation with your explanation about |
Updated. |
One spect that E.g.: const user = t.Object({
name: t.String(),
age: t.Optional(t.String()),
}); Requires: {
"name": "John",
"age": null
} instead of {
"name": "John"
} |
Why does prismabox generate types with
__nullable__
instead of justType.Optional
? I see there is generator forType.Optional
, but it isn't being used.For a model with a field like this:
I am getting this:
Where as I would expect
Also - this might be a separate issue, by why would prismabox add
{ additionalProperties: false }
to scalar values like strings and numbers?The text was updated successfully, but these errors were encountered: