title: In Typescript's generic class, how to return typeof T
body: <p>I have a generic class and I want to do something like this:</p>
  <pre><code>class MyClass&lt;T&gt; {
    getModel(): typeof T { return T; }
  }
  </code></pre>
  <p>How can I return T and define the return type?</p>
  <p>for the return type, I have seen someone using <code>new (...args) =&gt; T</code></p>
  <p>But I can't <code>return T</code> in typescript, it says:</p>
  <blockquote>
  <p>'T' only refers to a type, but is being used as a value here.</p>
  </blockquote>
  <p>How can I fix it?</p>
  <p><strong>Update 1:</strong> A different use case</p>
  <p>I modified the above generic class to an abstract class:</p>
  <pre><code>class Data {}
  
  abstract class MyClass&lt;T extends Data&gt; {
    abstract getModel(): typeof T;
  }
  </code></pre>
  <p>It gives error:
  <code>'T' only referes to a type, but is being used as a value here.</code></p>
  <p>But <code>T extends Data</code>. I can define a return type as <code>typeof Data</code>, but why can't I define a return type as <code>typeof T</code>?</p>