我是打字稿的新手。我正在使用此代码:
module app.controllers {
export class BarController {
}
}
module app.controllers {
export class MehController {
}
}
使用tsc
选项--module amd
和outFile app.js
我得到了这个结果:
var app;
(function (app) {
var controllers;
(function (controllers) {
var BarController = (function () {
function BarController() {
}
return BarController;
}());
controllers.BarController = BarController;
})(controllers = app.controllers || (app.controllers = {}));
})(app || (app = {}));
var app;
(function (app) {
var controllers;
(function (controllers) {
var MehController = (function () {
function MehController() {
}
return MehController;
}());
controllers.MehController = MehController;
})(controllers = app.controllers || (app.controllers = {}));
})(app || (app = {}));
生成了2个var app;
。我想知道它应该只产生一次。或者更好的是这样的事情:
var app;
(function (app) {
var controllers;
(function (controllers) {
var BarController = (function () {
function BarController() {
}
return BarController;
}());
controllers.BarController = BarController;
var MehController = (function () {
function MehController() {
}
return MehController;
}());
controllers.MehController = MehController;
})(controllers = app.controllers || (app.controllers = {}));
})(app || (app = {}));
这可能吗?如果是这样,那么如何实现呢?如果不是,那么可能是否有任何工具可以简化生成的javascript代码,就像我预期的结果一样?先谢谢!