json-to-ts
json-to-ts copied to clipboard
Treat null as a regular type and not an optional field
RE: https://github.com/MariusAlch/json-to-ts/issues/17 https://github.com/MariusAlch/json-to-ts/issues/5
By reading through the issues, I know the current handling of optional fields is by design, and I understand the reasoning, especially as JSON doesn't support undefined. I'm using this library as part of rikukissa/typehole and the expectation for many is to get null as one of the types in the union type instead of optional fields.
I've done the necessary changes here to support null
. Undefined and missing fields in array objects now cause the field to be marked as optional.
Not requesting for this PR to be merged, but I'm leaving this here for anyone who would find this behaviour useful @riku/json-to-ts