title: TypeScript: pass generic type as parameter in generic class
body: <p><strong>TypeScript:</strong> 
  I have a method in the DataProvider class with a method getTableData:</p>
  
  <pre><code>public static getTableData&lt;T extends DataObject&gt;(type: { new(): T}): Array&lt;T&gt; { ... }
  </code></pre>
  
  <p>this works perfectly when I code:</p>
  
  <pre><code>let speakers = DataProvider.getTableData(Speaker);  // where Speaker is a class
  </code></pre>
  
  <p>now I want to call this from a generic Class:</p>
  
  <pre><code>export class ViewModelBase&lt;T extends DataObject&gt; {   
    public getData(): Array&lt;T&gt; {
      return &lt;T[]&gt; DataProvider.getTableData(T);
    }
  }
  </code></pre>
  
  <p>Now I get a <em>Cannot find name 'T'</em> error for the T parameter I pass to getTableData. How should getTableData be called?</p>
  
  <p><strong>update</strong>:
  With the help of @Paleo I came up this:</p>
  
  <pre><code>export class ViewModelBase&lt;T extends DataObject&gt; {   
  
    constructor(private dataObjectClass: { new(): T}){}
  
    public getTableData(): Array&lt;T&gt; {
      return &lt;T[]&gt; DataProvider.getTableData&lt;T&gt;(this.dataObjectClass);
    }
  }
  </code></pre>
  
  <p>the thing is that although I have already told in:
  <code>class SpeakerViewModel extends ViewModelBase&lt;Speaker&gt; { ... }</code> 
  that I want it to be a ViewModel for <code>Speaker</code> I still have the instantiate the <code>SpeakerViewModel</code> like:</p>
  
  <p><code>let vm = new SpeakerViewModel(Speaker);</code></p>
  
  <p>although I have already told it is all about <code>Speaker</code>. I guess I still don't fully understand this.</p>