watzon
watzon11mo ago

Keep optional strings from getting converted to empty strings

I have a script which has a whole bunch of fields marked as string | undefined. For some reason though, fields with no value are coming though as empty strings instead of undefined. Is there any way to avoid this?
2 Replies
rubenf
rubenf11mo ago
you can't in the UI and it's a design decision so that there would be no difference between writing something and deleting and not writing anything. But you can check if the string is empty and mutate the variable to be undefined to have the behavior you seek
watzon
watzon11mo ago
Yeah I was just hoping to avoid that. Oh well. Not the end of the world.