title: In TypeScript how do I declare a generic with 2 arguments, where the first is a key of the second that returns a specific type?
body: <p>I'm looking to have a generic class like this one:</p>
  
  <pre class="lang-js prettyprint-override"><code>export abstract class Foo&lt;ID extends keyof T, T&gt; {
      bar(T t) {
          const s: string = t[ID];
      }
  }
  </code></pre>
  
  <p>Obviously the code above can't infer the type of <code>t[ID]</code> and we're getting an implicit <code>any</code>.
  How can I enforce using generics <code>T[ID]</code> will be a <code>string</code>?</p>