Is there a way to access the "export" object in TypeScript modules?

I am trying to use durandal and I need to getModuleId by passing the current module. My problem is that since I am using TypeScript, the lining object that is returned from the AMD module does not seem to be accessible using the Typescript code:

 export function checkModule(){ var a = system.getModuleId(??); } 

the compiled TS will be converted to this:

 function checkModule(){ var a = system.getModule(??); } exports.checkModule = checkModule; 

instead ?? I need to pass the exports object, which is defined in the compiled TS. Is there a way to do this, or is there a very easy way? thanks

+4
source share
2 answers

Below I use the following. You say: "There is an export variable" ... and it’s good :)

 declare var exports; var thisModule = exports; 
+5
source

Well, there is one way: cache this when you first call the activate method of the module:

 var _thisModule :any; export function activate(){ _thisModule = this; .... } 
0
source

Source: https://habr.com/ru/post/1480827/


All Articles