Is there a way to create non-anonymous AMD Modules in Typescript. When I define a module like this:
export module Bootstrapper {
export function run() {
var i = 0;
}
}
the generate code is:
define(["require", "exports"], function(require, exports) {
(function (Bootstrapper) {
function run() {
var i = 0;
}
Bootstrapper.run = run;
})(exports.Bootstrapper || (exports.Bootstrapper = {}));
})
How can I define a non-anomymous module like this:
define('bootstrapper', ["require", "exports"], function(require, exports) {
(function (Bootstrapper) {
function run() {
var i = 0;
}
Bootstrapper.run = run;
})(exports.Bootstrapper || (exports.Bootstrapper = {}));
})
This feature was recently added to the TypeScript master branch via this pull request. Declaring an AMD module name is with the following reference comment:
/// <amd-module name='MyModuleName'/>
will produce the following JavaScript:
define("MyModuleName", ["require", "exports"], function (require, exports) { ... }
As you can see in the file emitter.ts at line 1202 (make a search for " var dependencyList = "
) there is no implementation for it.
You can open an issue on codeplex about it.
As of TS 0.9.x it is not possible to name an AMD module. The TS compiler will only generate a define statement in the format
define( ['dep1', 'dep2', ..., 'depN'], function( __dep1__, __dep2__, ..., __depN__ ) {... } );
discussion on the TS forums : https://typescript.codeplex.com/discussions/451454
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