title: TypeScript Partial<T> type without undefined
body: <p>How to create a <em>kinda</em>-<code>Partial&lt;T&gt;</code> type, that doesn't allow <code>undefined</code> values?</p>
  
  <p>Here's an example:</p>
  
  <pre><code>interface MyType {
    foo: string
    bar?: number
  }
  
  const merge = (value1: MyType, value2: KindaPartial&lt;MyType&gt;): MyType =&gt; {
    return {...value1, ...value2};
  }
  
  
  
  const value = {
    foo: 'foo',
    bar: 42
  }
  
  merge(value, {});                          // should work
  merge(value, { foo: 'bar' });              // should work
  merge(value, { bar: undefined });          // should work
  merge(value, { bar: 666 });                // should work
  merge(value, { foo: '', bar: undefined }); // should work
  merge(value, { foo: '', bar: 666 });       // should work
  
  // now the problematic case:
  merge(value, { foo: undefined }); // this should throw an error
                                    // because MyType["foo"] is of type string
  </code></pre>
  
  <p>The type I'm looking for should:</p>
  
  <ul>
  <li>only accept keys that exist on the generic type (just like a normal <code>Partial&lt;T&gt;</code>)</li>
  <li>accept a subset of the keys of the generic type</li>
  <li><strong>but</strong> don't accept <code>undefined</code> if the generic type doesn't accept <code>undefined</code> for that key</li>
  </ul>
  
  <p>Is this possible?</p>
  
  <hr>
  
  <p>EDIT: I also created a issue at TypeScript repository, because this is weird and should throw an error at some point: <a href="https://github.com/Microsoft/TypeScript/issues/29701" rel="noreferrer">https://github.com/Microsoft/TypeScript/issues/29701</a> </p>