title: Define Mongoose Schema model with Typescript using Typings
body: <p>After upgrading my app from tsd to typings for typescript everything worked fine except the mongoose models. I can't figure how to configure the new changes, tried several methods but they seem to work. I lost the save and other methods set on the model by extending it with mongoose.Model. Here is how i had the setup before the breaking changes</p>
  
  <pre><code>import mongoose = require('mongoose');
  import {NextFunction} from 'express';
  let Schema = mongoose.Schema;
  
  interface IUser extends mongoose.Document {
      username: string;
      password: string;
  
      authenticate(password: string): boolean;
      findUniqueUsername(username: string, suffix: number, next: NextFunction): void;
  }
  
  interface IUserModel extends mongoose.Model&lt;IUser&gt; {
      hashPassword(password: string): string;
  }
  
  var UserSchema: mongoose.Schema = new Schema({
      username: {
         type: String,        
         required: 'Please fill in the user name',
         unique: true
      },
      password: {
         type: String
      }
  });
  
  UserSchema.methods.hashPassword = function (password) {...};
  UserSchema.methods.authenticate = function (password) {...};
  UserSchema.statics.findUniqueUsername = function (username, suffix, next) {...};
  
  var User = &lt;IUserModel&gt; mongoose.model('User', UserSchema);
  
  export {IUser, IUserModel, User}
  </code></pre>
  
  <p>I am also getting an error:</p>
  
  <blockquote>
    <p>An interface may only extend a class or another" for the IUserModel
    extends mongoose.Modelinterface.</p>
  </blockquote>
  
  <p>This all worked great fine until I changed to using Typings. Whats the new way of doing this.</p>