title: Create original type by adding fields to an Omit type combined with generics
body: <p>In typescript you can re-create a type with fields removed using <code>Omit</code> by adding them:</p>
  <pre><code>interface Animal {
    name: string
  }
  
  interface Dog extends Animal {
    goodboy: true
  }
  
  const makeDog = (name: string, attributes: Omit&lt;Dog, 'name'&gt;): Dog =&gt; ({
    ...attributes,
    name
  })
  </code></pre>
  <p>However, when you try to do this using a generic type, it fails with an error:</p>
  <pre><code>// Type 'Omit&lt;T, &quot;name&quot;&gt; &amp; { name: string; }' is not assignable to type 'T'.
  // 'Omit&lt;T, &quot;name&quot;&gt; &amp; { name: string; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Animal'.
  const makeAnimal = &lt;T extends Animal&gt;(name: string, attributes: Omit&lt;T, 'name'&gt;): T =&gt; ({
    ...attributes,
    name
  })
  </code></pre>
  <p>Is there a way to create the <code>makeAnimal</code> function?</p>
  <p><a href="https://www.typescriptlang.org/play?ssl=17&amp;ssc=3&amp;pln=14&amp;pc=1#code/JYOwLgpgTgZghgYwgAgIImAWzgG2QbwChlkQ5MIAuZAZzClAHNCBfQw0SWRFAEQHtGyCAA9IIACY00GbHiIlG-fhIBG-AJ7V6AVwit2CfiDrJsAawgChAXmQAKMhWp0GIRgBpkcMPWCqdSBpqAHlMYDAAHmsvAHInCFiAPgBKamtkGySHBWQAOgKfPwCgj2JScn0WFMNjUwsIdCxcTORIgBVhMQhJaSa5JMdKlz93LyKGEohg5DCIjriE5LTkTqyc8oK8if9A6bKSBNYawiMTMGQYHB0YGA0ARlaG63tYgDFr241Yr3xkJRU6i0yF0KGqpzqFyuNzuACYnnBLP1cNFBIN3p87j8CP9lGpNNooHpkOCgA" rel="nofollow noreferrer">Typescript playground</a></p>