title: How can I make a generic TypeScript interface extend from another generic interface?
body: <p>I have an interface, with several elements:</p>
  
  <pre><code>export interface Item {
    id: string;
    code: string;
    createdAt: string;
    updatedAt: string;
    level: number;
    seq: number;
    hasChildren: boolean;
  
    parentObject?: Item;
    children?: Item[];
  }
  </code></pre>
  
  <p>I wanted something like the <code>Partial&lt;T&gt;</code> which I helpfully discovered here:
  <a href="https://stackoverflow.com/questions/39713349/make-all-properties-within-a-typescript-interface-optional#40076355">Make all properties within a Typescript interface optional</a></p>
  
  <p>However, I would like to make <strong>one</strong> of the fields mandatory. I implemented this:</p>
  
  <pre><code>export interface ItemUpdate extends Partial&lt;Item&gt; {
    id: string;
  }
  </code></pre>
  
  <p>and that compiled well. However, I would like to avoid declaring it for each interface. For that, I made it more generic:</p>
  
  <pre><code>export interface UpdateOf&lt;T&gt; extends Partial&lt;T&gt; {
    id: string; // the ID is the only mandatory value for an update
  }
  </code></pre>
  
  <p>However, that is no longer compiling, returning the following error:</p>
  
  <pre><code>error TS2312: An interface may only extend a class or another interface.
  </code></pre>
  
  <p>I am running Angular 6.1.5, which comes with Typescript 2.9 (as far as I know).</p>