Closed Roxas92 closed 2 years ago
Thanks for sharing. This behavior is intentional, since it is technically possible for strapi to send a null value.
This happens if you create a non required field and create an entry for the given content type where the value has not been set. It can also happen of you create some entries of a type and the later add the required fields. The entry would still have a null value and thus could create runtime errors in your typescript application (which is the whole point of typescript).
This issue have been described in #14 and should be implemented as such.
I am going to close this issue, but if you still want to contribute you are much welcome. If you want to resolve your issue you can make a PR for #14. Please comment on the issue of you start working on it :)
Thank you for the explanation. :) I haven't thought about it that way. But makes sense. I'll check if I can find a solution for #14 and let you know if I find something.
When using an field of the type "enumeration" an additional
null
gets pushed to the array options regardless if the field is required or not.To ensure that null only gets pushed when the field is not required, an additional if-check is required.