title: Generic way to convert all instances of null to undefined in Typescript
body: <p>I am wanting to write a function that converts all instances of a property of any object that is null to undefined. Many of my objects have nested objects as properties or arrays of values/objects.</p>
  
  <p>My first thought when approaching the problem is to use generics to attempt to catch the type of each of the properties with a generic type and then to convert the value of that property from null to undefined as needed.</p>
  
  <p>I am hoping to write a function that is generic enough to work across any of the different types and sized objects I have across my code code base.</p>
  
  <p>I haven't been able to find an easy way to have an unknown number of generic types, so my next thought is that I'll have to use the any type everywhere. Is there a way around this?</p>
  
  <p>I'd also love some advice on the approach/algorithm itself as well. My thought is that I'll probably need to recursively check each property to see if it itself is an object with sub properties, and I'll also need to iterate any arrays found that might have a null value as well, or have an object that will need to be recursively checked as well.</p>
  
  <p>The problems/questions I need to solve/answer:</p>
  
  <ol>
  <li>Should I use Generics or Any?</li>
  <li>If i use generics is there a way to dynamically assign new generic types as a new type  is found?</li>
  <li>Does typescript have an easier way to recursively parse objects?</li>
  </ol>
  
  <p>My current approach is something like:</p>
  
  <p><code>inputObjectKeys.map(key, index) =&gt;</code></p>
  
  <p>then have a function that converts null to undefined, ignores non object types, and recurses if its an object.</p>
  
  <p>I'm assuming I'd want to use a Breadth First Search or Depth First Search (I'm leaning towards Breadth First Search for this particular task). I'm assuming since i need to visit every node i might be better off with DFS simply because of the memory usage.</p>