0
votes

In javascript, when I define an AMD module I create and return a reference to the exposed portions of the module. When I use Typescript, I 'export' items, which causes them to be added to the 'exports' variable.

//javascript module
define(["require", "exports"], function(require, exports) {
    exports.message = function(s) {
        console.log(s);
    }
}

In Typescript, I would like to get a reference to the external module from within the module, while it's being defined. Basically, I'd like access to the generated 'exports' variable, but can't find a way. Among other reasons, I'd like to be able to call Duradal's system.getModuleId and pass the current module.

Thanks

1
Given that TypeScript is - for all intents and purposes - JavaScript, ask yourself how you would do this in JavaScript. If you cannot do it in JS, you cannot do it in TS. - x0n

1 Answers

1
votes
declare var exports;

export var n = 4;
console.log(exports);

Produces:

define(["require", "exports"], function(require, exports) {
    exports.n = 4;
    console.log(exports);
});