title: Cannot extend base class with Mongoose and Typescript in NodeJS
body: <p>I'm attempting to use Mongoose 4.5.4 and <a href="https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7e4710a23ce3779826c4d26d1cf637851924a299/mongoose/mongoose.d.ts" rel="nofollow">it's typings</a> in NodeJS with Typescript (obviously) while utilizing the Repository Pattern.</p>
  
  <p>RepositoryBase:</p>
  
  <pre><code>export class RepositoryBase&lt;T extends mongoose.Document&gt; implements IRead&lt;T&gt;, IWrite&lt;T&gt; {
      private _model: mongoose.Model&lt;mongoose.Document&gt;;
  
      constructor(schemaModel: mongoose.Model&lt;mongoose.Document&gt;) {
          this._model = schemaModel;
      }
  
      create(item: T): mongoose.Promise&lt;mongoose.model&lt;T&gt;&gt; {
          return this._model.create(item);
      }
  
      //......
      //Additional CRUD methods excluded for brevity
  }
  </code></pre>
  
  <p>UserRepository:</p>
  
  <pre><code>export class UserRepository extends RepositoryBase&lt;IUserModel&gt; {
      constructor() {
          super(UserSchema);
      }
  }
  </code></pre>
  
  <p>I have the following type error on the call to <code>super()</code> from <code>UserRepository</code></p>
  
  <p><code>[ts] 
  Argument of type '&lt;U&gt;(name: string) =&gt; IModelConstructor&lt;U&gt; &amp; EventEmitter' is not assignable to parameter of type 'IModelConstructor&lt;Document&gt; &amp; EventEmitter'.
    Type '&lt;U&gt;(name: string) =&gt; IModelConstructor&lt;U&gt; &amp; EventEmitter' is not assignable to type 'IModelConstructor&lt;Document&gt;'.
      Property 'findById' is missing in type '&lt;U&gt;(name: string) =&gt; IModelConstructor&lt;U&gt; &amp; EventEmitter'.
  import UserSchema</code></p>
  
  <p>Does anyone know why? My creation of my model (<code>UserSchema</code>) is very simple:
  <code>let model = mongooseConnection.model&lt;IUserModel&gt;("Users", UserSchema.schema);</code></p>
  
  <p>I would much appreciate a push in the right direction.</p>