title: Typescript: Type inference when using decorator
body: <p>I wonder why when I use decorators or annotations in Typescript on a class. The compiler can't infer the new type of the class. If I don't use decorators and use the old way to do this in ES5 (ie. call manually the decorator) it obviously works.</p>
  
  <p>For instance, here a sample that shows the issue:</p>
  
  <pre><code>function decorate(Target: typeof Base): IExtendedBaseConstructor {
    return class extends Target implements IExtendedBase {
      public extendedtMethod(): number {
        return 3;
      }
    };
  }
  
  interface IBase {
    baseMethod(): number;
  }
  
  interface IExtendedBase extends Base {
    extendedtMethod(): number;
  }
  
  interface IExtendedBaseConstructor {
    new(): IExtendedBase;
  }
  
  @decorate
  class Base implements IBase {
    public baseMethod(): number {
      return 5;
    }
  }
  
  const test = new Base();
  test.baseMethod(); // OK
  test.extendedtMethod(); // NOT OK, typescript think, Base is still Base but we decorated it.
  </code></pre>
  
  <p>With the older way, it works:</p>
  
  <pre><code>class Base implements IBase {
    public baseMethod(): number {
      return 5;
    }
  }
  
  const ExtendedBase = decorate(Base);
  
  const test = new ExtendedBase();
  test.baseMethod(); // OK
  test.extendedtMethod(); // OK
  </code></pre>
  
  <p>Thanks in advance.</p>