-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionDuplicateAn existing issue was already createdAn existing issue was already createdSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
It seems that one of the likeable features of TypeScript, compared to Babel lets say, is that it emits readable code.
Consider the following code:
X.ts:
namespace a.b.x {
class X {
}
}Y.ts:
namespace a.b.y {
class y {
}
}This emits:
var a;
(function (a) {
var b;
(function (b) {
var x;
(function (x) {
var X = (function () {
function X() {
}
return X;
})();
})(x = b.x || (b.x = {}));
})(b = a.b || (a.b = {}));
})(a || (a = {}));
var a;
(function (a) {
var b;
(function (b) {
var y;
(function (y_1) {
var y = (function () {
function y() {
}
return y;
})();
})(y = b.y || (b.y = {}));
})(b = a.b || (a.b = {}));
})(a || (a = {}));There's a lot of code redundancy, which can really clutter the emitted output for projects that rely heavily on namespaces.
Wouldn't it be nice if we could just do something like this:
namespace a.b {
export namespace x {
/// include X.ts
}
export namespace y {
/// include Y.ts
}
}The include statement simply places the included file into the script during pre-compilation.
My guess is that this is already partly implemented with /// reference, only that ///reference doesn't seem to work unless it's either the first line, or one succeeding another /// reference.
Metadata
Metadata
Assignees
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionDuplicateAn existing issue was already createdAn existing issue was already createdSuggestionAn idea for TypeScriptAn idea for TypeScript