You can achieve this using the recursive function. Here's an example implementation:
index.ts466 chars17 lines
This function takes an object as the input and returns a new object where all undefined values are replaced with null. It recursively loops through all properties of the object and if a property is undefined, it replaces it with null. If the property is an object, it recursively calls the function with that object as the input. If the property is not an object or undefined, it copies the value to the new object.
Here's an example usage:
index.ts298 chars13 lines
This will output a new object where all undefined values are replaced with null.
gistlibby LogSnag