我有两个文件
应用程序.js
///<reference path='mongodb.d.ts'/>
///<reference path='MyDatabase.ts'/>
module MyModule {
import mongodb = module("mongodb");
new mongodb.Server();
var db = new MyDatabase(); // this will not work with first import line in Database.js, but work with second
}
MyDatabase.js
///<reference path='mongodb.d.ts'/>
import mongodb = module("mongodb"); // adding this line here, will cause that app.js will not see MyDatabase class
module MyModule {
import mongodb = module("mongodb"); // adding this line this will cause that classes in this module cant use mongodb
export class MyData {
_id: mongodb.Id; // second import line will cause this to be compilation error, with first line it works
}
export class MyDatabase {
public test(): void {
//with second line i can access mongodb here
}
}
}
所以问题是,我错过了什么?我应该如何导入 mongodb?