Do not emit __extends if --noEmitHelpers is set

This commit is contained in:
Mohamed Hegazy 2015-05-01 16:29:41 -07:00
parent 93bf569432
commit 101aedbf4e
3 changed files with 27 additions and 8 deletions

View File

@ -5487,9 +5487,6 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
}
write("[\"require\", \"exports\"");
if (compilerOptions.noEmitHelpers) {
write(", \"__extends\"");
}
if (aliasedModuleNames.length) {
write(", ");
write(aliasedModuleNames.join(", "));
@ -5499,9 +5496,6 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
write(unaliasedModuleNames.join(", "));
}
write("], function (require, exports");
if (compilerOptions.noEmitHelpers) {
write(", __extends");
}
if (importAliasNames.length) {
write(", ");
write(importAliasNames.join(", "));
@ -5623,7 +5617,6 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
// Only emit helpers if the user did not say otherwise.
if (!compilerOptions.noEmitHelpers) {
// Only Emit __extends function when target ES5.
// For target ES6 and above, we can emit classDeclaration as is.
if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitExtends)) {
@ -5643,7 +5636,6 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
writeLines(paramHelper);
paramEmitted = true;
}
}
if (isExternalModule(node) || compilerOptions.separateCompilation) {

View File

@ -0,0 +1,17 @@
//// [noEmitHelpers2.ts]
function decorator() { }
@decorator
class A { }
//// [noEmitHelpers2.js]
function decorator() { }
var A = (function () {
function A() {
}
A = __decorate([
decorator
], A);
return A;
})();

View File

@ -0,0 +1,10 @@
// @noemithelpers: true
// @target: es5
function decorator() { }
@decorator
class A {
constructor(a: number, b: string) {
}
}