title: TypeScript: remove key from type/subtraction type
body: <p>I want to define a generic type <code>ExcludeCart&lt;T&gt;</code> that is essentially <code>T</code> but with a given key (in my case, <code>cart</code>) removed. So, for instance, <code>ExcludeCart&lt;{foo: number, bar: string, cart: number}&gt;</code> would be <code>{foo: number, bar: string}</code>. Is there a way to do this in TypeScript?</p>
  
  <p>Here's why I want to do this, in case I'm barking up the wrong tree: I'm converting an existing JavaScript codebase to TypeScript, which contains a decorator function called <code>cartify</code> that takes a React component class <code>Inner</code> and returns another component class <code>Wrapper</code>.</p>
  
  <p><code>Inner</code> should take a <code>cart</code> prop, and zero or more other props. <code>Wrapper</code> accepts a <code>cartClient</code> prop (which is used to generate the <code>cart</code> prop to pass to <code>Inner</code>), and any prop that <code>Inner</code> accepts, <em>except</em> <code>cart</code>.</p>
  
  <p>In other words, once I can figure out how to define <code>ExcludeCart</code>, I want to do this with it:</p>
  
  <pre><code>function cartify&lt;P extends {cart: any}&gt;(Inner: ComponentClass&lt;P&gt;) : ComponentClass&lt;ExcludeCart&lt;P&gt; &amp; {cartClient: any}&gt;
  </code></pre>