title: Is it possible in typescript to have a function return the type of a class that extends it
body: <pre><code>export class Base {
      static getSomething():typeof this //&lt;-- change this?
      {
          var type = typeof this;
          return new this['type']();
      }
  }
  export class Foo extends Base {
      publicVar:string = 'getThis!';
  }
  
  var foo:Foo = Foo.getSomething();
  var success:string = foo.publicVar;
  </code></pre>
  
  <p>the above returns an error because the compiler says Foo.getSomething will return a Base, not a Foo.
  I wonder if there is another way that lets me call a static function of Foo that the compiler knows will return a Foo.</p>
  
  <p>Ofcourse I can implement it explicitly in Foo, and thus in every class that extends Base, or I could simply typecast it:</p>
  
  <pre><code>var foo:Foo = &lt;Foo&gt; Foo.getSomething();
  </code></pre>
  
  <p>But I was wondering if there is a way without having to do either of those things, since I'll be using this method <em>a lot</em></p>