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
TypeScript supports export = to model the traditional CommonJS and AMD workflow. The export = syntax specifies a single object that is exported from the module. This can be a class, interface, namespace, function, or enum.
The export declaration is used to export values from a JavaScript module. Exported values can then be imported into other programs with the import declaration or dynamic import.
Use named exports to export a function in TypeScript, e.g. export function sum() {} . The exported function can be imported by using a named import as import {sum} from './another-file' . You can use as many named exports as necessary in a single file.
module. Exports is the object that is returned to the require() call. By module. exports, we can export functions, objects, and their references from one file and can use them in other files by importing them by require() method.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With