這裏是.js文件:如何用javascript模塊插入打字稿文件
var mongoose=require('mongoose');
var express=require('express');
var app=express();
var connect=mongoose.connect("mongodb://localhost:27017/techo2log");
var schema=mongoose.Schema;
var userschema=new schema(
{
name:String,
age:Number,
address:String,
created_at:Date,
updated_at:Date,
}
);
var User=mongoose.model('User',userschema);
userschema.method.dudify=function()
{
this.name=this.name+'-dude';
return this.name;
}
//making the model available to the external file
module.exports=User;
我想使用的用戶模塊中我喜歡的類型的腳本file.How我應該寫在上面的代碼打字稿定義文件這樣我可以導入我的.ts文件。
的[如何導入一個js庫沒有打字稿文件定義文件]可能的複製(http://stackoverflow.com/問題/ 22842389/how-to-import-a-js-library-without-definition-file-in-typescript-file) –