title: Omitting all properties in an object which are `undefined`
body: <p>I have a type like this:</p>
  <pre><code>  {
      a: number,
      b: number,
      c: undefined
    }
  </code></pre>
  <p>And I want to map it to a type like this:</p>
  <pre><code>{
    a: number,
    b: number
  }
  </code></pre>
  <p>i.e. I want to omit all keys where the type of the value is <code>undefined</code> by definition. The type comes from a generic so I obviously cannot do it manually.</p>
  <p>I know I can map a type to another type with a mapper, so I tried mapping <code>undefined</code> to <code>never</code>:</p>
  <pre><code>type TryOmitUndefined&lt;K&gt; = {
    [k in keyof K]: K[k] extends undefined ? never : K[k]
  }
  </code></pre>
  <p>But this doesn't work at all.</p>
  <p>Is it possible in current TypeScript to omit keys from a type based on their value?</p>
  <h2>Bonus question</h2>
  <p>Can I map this</p>
  <pre><code>{
    a: number,
    b: number | undefined,
    c: undefined
  }
  </code></pre>
  <p>to this?</p>
  <pre><code>{
    a: number,
    b?: number
  }
  </code></pre>