title: Passing class as parametr with generics
body: <p><a href="http://goo.gl/bSOKQo" rel="nofollow">Here is live example</a>(Sorry, had to use url shortener, link characters break markup)
  TypeScript version 1.6.2</p>
  
  <p>I have two services across my angular2 application. Let's name them ServiceA and ServiceB. Each one of them, have similar data structure, so I decided to use <code>extends</code> to not write same code twice. The class which will provide data structure is called Pages and looks like this:</p>
  
  <pre><code>class Pages {
    public pages = [];
    private active: number = 0;
  
    get current() {
      return this.pages[this.active];
    }
  
    constructor(private page, public name: string) { }
  
    changeActive(page: number): void {
      this.active = page;
    }
  
    addPage(): void {
      this.pages.push(
        new this.page(this.name + (this.pages.length + 1))
      );
    }
  }
  </code></pre>
  
  <p><code>pages</code> array will contains class instances unique for each service. Here is an example of one for ServiceA:</p>
  
  <pre><code>// ServiceA.pages will be filled with instanced of this class.
  // ServiceB.pages will use different class but the constructor 
  // will be simmilar(will take only one argument name: string)
  class PageA {
    public uniquePropertyA: string = 'Hello World!';
    constructor(public name: string) { }
    // unique methods of PageA
  }
  </code></pre>
  
  <p>Services will look quite similar. Here preview of ServiceA:</p>
  
  <pre><code>class ServiceA extends Pages {
    constructor() {
      super(PageA, 'ServiceA #');
    }
  }
  
  // demo
  var sA = new ServiceA();
  sA.addPage();
  sA.current. // Hey there is no auto complete!
  </code></pre>
  
  <p>This example works fine, however I do not get autocomplete each page because its type is <code>any</code>. I was trying to use "generics" to make it work, sadly with no success but <a href="http://goo.gl/kU5H2Y" rel="nofollow">here it is</a>. Basicly I want to know which constructor I passed to <code>Pages</code> class, so I can get right types.</p>
  
  <p>I hope you guys can help me with this one.</p>