-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Out of ScopeThis idea sits outside of the TypeScript language design constraintsThis idea sits outside of the TypeScript language design constraintsSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Currently, you have to write TypeScript files two different ways to either output them as Internal or External Modules. Can we have a smarter compiler that can create an Internal or External Modules from the same TypeScript file using the module option?
Suggestion, create all classes in the internal module way.
module namespace {
export class ClassName {
constructor() {
}
public methodName():void {
}
}
}
which would create the modular version
define(["require", "exports"], function(require, exports) {
var ClassName = (function () {
function ClassName() {
}
ClassName.prototype.methodName = function () {
}
return ClassName;
})();
return ClassName;
});
or could create a none modular version from the same file.
var namespace;
(function (namespace) {
var ClassName = (function () {
function ClassName() {
}
ClassName.prototype.methodName = function () {
};
return ClassName;
})();
namespace.ClassName = ClassName;
})(namespace || (namespace = {}));
Initially I created a framework using the internal module way but then had to port it to the external module way for another project. Now I am maintaining two code bases and the only difference is how the files are structured so that I can create an internal or external module versions.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Out of ScopeThis idea sits outside of the TypeScript language design constraintsThis idea sits outside of the TypeScript language design constraintsSuggestionAn idea for TypeScriptAn idea for TypeScript