title: Declaring function where the parameter is a class, returning an instance of that class?
body: <p>I am trying to write the TypeScript definition for a library I use. It has a Plugin system that I have no control of other than plugins must extend <code>Plugin</code>.  The <code>PluginManager</code> has a function </p>
  
  <pre><code>add(plugin: any, ...parameters: any[]): any;
  </code></pre>
  
  <p>Where parameter plugin is a Class (Apple.Tree) and returns an instanceof Apple.Tree. Apple.Tree extends Plugin. </p>
  
  <p>Is there any way to make this a generic function and keep the type? </p>
  
  <p>I tried this:</p>
  
  <pre><code>add&lt;T extends Plugin&gt;(plugin: T, ...parameters: any[]): T;
  </code></pre>
  
  <p>When I try to call it this function though, it says. <code>Argument of type "typeof Apple.Tree" is not assignable to parameter of type "Plugin"</code></p>
  
  <p>It says a property is missing in the Apple.Tree. However, since Apple.Tree extends Plugin, it is complaining over something which is there. I have a feeling it might have to do with this generic function.</p>
  
  <p>I would appreciate any advice.</p>