Skip to content

Commit 101aedb

Browse files
committed
Do not emit __extends if --noEmitHelpers is set
1 parent 93bf569 commit 101aedb

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

src/compiler/emitter.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5487,9 +5487,6 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
54875487
}
54885488

54895489
write("[\"require\", \"exports\"");
5490-
if (compilerOptions.noEmitHelpers) {
5491-
write(", \"__extends\"");
5492-
}
54935490
if (aliasedModuleNames.length) {
54945491
write(", ");
54955492
write(aliasedModuleNames.join(", "));
@@ -5499,9 +5496,6 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
54995496
write(unaliasedModuleNames.join(", "));
55005497
}
55015498
write("], function (require, exports");
5502-
if (compilerOptions.noEmitHelpers) {
5503-
write(", __extends");
5504-
}
55055499
if (importAliasNames.length) {
55065500
write(", ");
55075501
write(importAliasNames.join(", "));
@@ -5623,7 +5617,6 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
56235617

56245618
// Only emit helpers if the user did not say otherwise.
56255619
if (!compilerOptions.noEmitHelpers) {
5626-
56275620
// Only Emit __extends function when target ES5.
56285621
// For target ES6 and above, we can emit classDeclaration as is.
56295622
if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitExtends)) {
@@ -5643,7 +5636,6 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
56435636
writeLines(paramHelper);
56445637
paramEmitted = true;
56455638
}
5646-
56475639
}
56485640

56495641
if (isExternalModule(node) || compilerOptions.separateCompilation) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [noEmitHelpers2.ts]
2+
3+
function decorator() { }
4+
5+
@decorator
6+
class A { }
7+
8+
//// [noEmitHelpers2.js]
9+
function decorator() { }
10+
var A = (function () {
11+
function A() {
12+
}
13+
A = __decorate([
14+
decorator
15+
], A);
16+
return A;
17+
})();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @noemithelpers: true
2+
// @target: es5
3+
4+
function decorator() { }
5+
6+
@decorator
7+
class A {
8+
constructor(a: number, b: string) {
9+
}
10+
}

0 commit comments

Comments
 (0)