title: Typescript - Generic type extending itself
body: <p>I recently came across something that looked like this:</p>
  
  <pre><code>interface Test&lt;T extends Test&lt;T&gt;&gt; {
    a: number;
    b: T;
  }
  
  function foo &lt;T extends Test&lt;T&gt;&gt;(el: T): T {
    ...
  }
  </code></pre>
  
  <p>I have to say I am a bit perplexed as to what exactly this is, and why something like this would be required. I've been through the <a href="https://www.typescriptlang.org/docs/handbook/generics.html" rel="noreferrer">Generics section</a> of the Typescript handbook but couldn't find anything similar.</p>
  
  <p>What does that interface achieve that can't be done with something like the following?</p>
  
  <pre><code>interface Test&lt;T&gt;
  </code></pre>
  
  <p>Can anyone shed some light on this?</p>