title: remove null or undefined from properties of a type
body: <p>I need to declare a type such that removes the undefined from its property types.</p>
  
  <p>Suppose we have:</p>
  
  <pre><code>type Type1{
    prop?: number;
  }
  
  type Type2{
    prop: number | undefined;
  }
  
  type Type3{
    prop: number;
  }
  </code></pre>
  
  <p>I need to define a generic type called <code>NoUndefinedField&lt;T&gt;</code> such that <code>NoUndefinedField&lt;Type1&gt;</code> gives the same type as <code>Type3</code> and the same type as <code>NoUndefinedField&lt;Type2&gt;</code>.</p>
  
  <p>I tried this</p>
  
  <pre><code>type NoUndefinedField&lt;T&gt; = { [P in keyof T]: Exclude&lt;T[P], null | undefined&gt; };
  </code></pre>
  
  <p>But it only works for <code>Type2</code>.</p>