title: Have Class<T extends { [key: string]: any }> implement T
body: <p>I have an injectable <code>Class&lt;T extends { [key: string]: any }&gt;</code> which has the purpose of obtaining a Generic Object. Such as:</p>
  
  <pre><code>interface Home {
    darkTheme: boolean;
    userType: number;
  }
  </code></pre>
  
  <p>and then I would inject my class like:</p>
  
  <pre><code>constructor(myClass: Class&lt;Home&gt;) {}
  </code></pre>
  
  <p>this works great for some methods that live inside my class. However, I want the class to be aware that its body has the keys of T as properties also. In a way that this:</p>
  
  <pre><code>const userType = this.myClass.userType // acknowledges it exists
  </code></pre>
  
  <p>is ok by typescript.</p>
  
  <p>TS doesn't throw an error with this, and <code>userType</code> would get the desired value. But this happens with Typescript being ignorant that the property exists in the body of <code>myClass</code>.</p>
  
  <p><strong>So how can I tell Typescript that <code>myClass&lt;T&gt;</code> has a body <code>T</code>?</strong></p>
  
  <p>I have tried:</p>
  
  <pre><code>class myClass&lt;T extends { [key: string extends keyof T]: any}&gt; // nope
  
  class myClass&lt;T extends { [key: string]: any } implements/ extends T&gt; // also nope
  
  // I tried overloading
  interface myClass&lt;T extends { [key: string]: any }&gt; {
    [key: K keyof T]: T[K]; // don't know what 'K' is;
  }
  
  interface myClass&lt;T extends { [key: string]: any }&gt; {
    [key: keyof T]: T[keyof T]; // interfaces don't like mapped types
  }
  </code></pre>
  
  <p>and little more. If you have any idea how can I achieve this, or if it's possible at all, I'd be happy to read you! :D thanks.</p>