An option to turn off nullable union field spec?
Closed this issue · 3 comments
tme321 commented
I wish there was some kind of toggle for nullable fields. I don't need "null | " scattered throughout my definitions and an option to not generate that would be great.
MariusAlch commented
I believe it would be nice in both the extension and the lib to have a config something like "nullableAsOptional" which would leave nullable types as optional. Currently I dont have a lot of time but I'll keep this on my todo list and update this with any news. If any one wants to have a shot at this you can create a pull request.
MariusAlch commented
Since I was already doing null types as optional, when null is the only expected type. Example
{ field: null }
// converts to
interface RootObject {
field?: any;
}
I decided things like this should work in similar manner:
[
{ field: null },
{ field: 42 }
]
// should convert to
interface RootObject {
field?: number;
}
// and not (current version)
interface RootObject {
field: null | number;
}
MariusAlch commented
solved with 298f00b closing the issue