问题
I am trying to use durandal and I need to getModuleId
by passing the current module. My problem is that as I am using TypeScript, the underlaying object which is returned from AMD module seems not to be accessible by Typescript code:
export function checkModule(){
var a = system.getModuleId(??);
}
the compiled TS will be converted into this:
function checkModule(){
var a = system.getModule(??);
}
exports.checkModule = checkModule;
instead of ??
I need to pass exports
object which is defined in compiled TS.
Is there anyway to do that or there is a much simple way?
thanks
回答1:
The following is what I use. You are saying "There is an exports variable out there" ... and well there is :)
declare var exports;
var thisModule = exports;
回答2:
Well there is one way, to cache the this
in the first call to activate
method of module:
var _thisModule :any;
export function activate(){
_thisModule = this;
....
}
来源:https://stackoverflow.com/questions/16555506/is-there-a-way-to-access-exports-object-in-typescript-modules