如果我在两个不同的命名空间中有一个具有两种类型的文件。生成的订单很重要。
export module Shapes {
export module Weird{
export class weirdshape extends Normal.normalshape{
public x = 3;
}
}
export module Normal{
export class normalshape {
public y = 4;
}
}
}
这将产生
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
define(["require", "exports"], function(require, exports) {
(function (Shapes) {
(function (Weird) {
var weirdshape = (function (_super) {
__extends(weirdshape, _super);
function weirdshape() {
_super.apply(this, arguments);
this.x = 3;
}
return weirdshape;
})(Normal.normalshape);
Weird.weirdshape = weirdshape;
})(Shapes.Weird || (Shapes.Weird = {}));
var Weird = Shapes.Weird;
(function (Normal) {
var normalshape = (function () {
function normalshape() {
this.y = 4;
}
return normalshape;
})();
Normal.normalshape = normalshape;
})(Shapes.Normal || (Shapes.Normal = {}));
var Normal = Shapes.Normal;
})(exports.Shapes || (exports.Shapes = {}));
var Shapes = exports.Shapes;
});
按照这个顺序,这将失败。因为尚未定义 Shapes.Normal.normalshape。
在打字稿中是否有适当的方法可以将模块用作适当的命名空间?