title: Mongoose+Typescript Scheme export scheme
body: <p>Hello I try rewriting my code from simple js to typescript and have some problems with mongoose schemas...</p>
  
  <pre><code>/// &lt;reference path="../typings/tsd.d.ts" /&gt;
  import * as mongoose from 'mongoose';
  import * as bcrypt from "bcrypt";
  
  var SALT_WORK_FACTOR = 10;
  var mongodbURL = 'mongodb://localhost/test';
  var mongodbOptions = {};
  
  mongoose.connect(mongodbURL, mongodbOptions);
  
  var Schema = mongoose.Schema;
  
  // User schema
  var User = new Schema({
      username: { type: String, required: true, unique: true },
      password: { type: String, required: true },
      is_admin: { type: Boolean, default: false },
      created: { type: Date, default: Date.now }
  });
  
  // Bcrypt middleware on UserSchema
  User.pre('save', function(next) {
      var user = this;
  
      if (!user.isModified('password')) return next();
  
      bcrypt.genSalt(SALT_WORK_FACTOR, function(err, salt) {
          if (err) return next(err);
  
          bcrypt.hash(user.password, salt, function(err, hash) {
              if (err) return next(err);
              user.password = hash;
              next();
          });
      });
  });
  
  //Password verification
  User.methods.comparePassword = function(password, cb) {
      bcrypt.compare(password, this.password, function(err, isMatch) {
          if (err) return cb(err);
          cb(isMatch);
      });
  };
  
  var userModel: mongoose.Model&lt;any&gt; = mongoose.model("User", User);
  
  //Define Models
  
  // Export Models trying ALL WAYS (((((
  
  declare var exports: any;
  exports.userModel = userModel;
  
  (module).exports = userModel;
  
  exports = {
      userModel: userModel
  } 
  
  export = userModel;  // EXPORT
  </code></pre>
  
  <p>but when I compile *.ts amd import this file i see: </p>
  
  <pre><code>import {userModel} from '../config/mongo_database';
  </code></pre>
  
  <blockquote>
    <p>has no exported member 'userModel'.</p>
  </blockquote>
  
  <p>OR</p>
  
  <pre><code>import db = require('../config/mongo_database');
  </code></pre>
  
  <blockquote>
    <p>Property 'userModel' does not exist on type 'Model'</p>
  </blockquote>
  
  <p>but <code>console.log(db)</code> show me</p>
  
  <pre><code>{ userModel: 
     { [Function: model]
       base: 
        { connections: [Object],
          plugins: [],
          models: [Object],
          modelSchemas: [Object],
          options: [Object] },
       modelName: 'User',
       model: [Function: model],
  </code></pre>
  
  <p>............</p>
  
  <p>is there any methods which do not use TS combo (interface,class,schema,export)  and simply uses mongoose schemas? )</p>
  
  <p>P.S. sorry for my english..</p>