Skip to content

Commit 1c40032

Browse files
committed
Fixes his in decorator helpers
1 parent a906076 commit 1c40032

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+261
-249
lines changed

src/compiler/emitter.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var __extends = this.__extends || function (d, b) {
3434

3535
// emit output for the __decorate helper function
3636
const decorateHelper = `
37-
var __decorate = this.__decorate || function (decorators, target, key, desc) {
37+
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) {
3838
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
3939
switch (arguments.length) {
4040
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
@@ -45,13 +45,15 @@ var __decorate = this.__decorate || function (decorators, target, key, desc) {
4545

4646
// emit output for the __metadata helper function
4747
const metadataHelper = `
48-
var __metadata = this.__metadata || function (k, v) {
48+
if (typeof __metadata !== "function") __metadata = function (k, v) {
4949
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5050
};`;
5151

5252
// emit output for the __param helper function
5353
const paramHelper = `
54-
var __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } };`;
54+
if (typeof __param !== "function") __param = function (paramIndex, decorator) {
55+
return function (target, key) { decorator(target, key, paramIndex); }
56+
};`;
5557

5658
let compilerOptions = host.getCompilerOptions();
5759
let languageVersion = compilerOptions.target || ScriptTarget.ES3;

tests/baselines/reference/classExpressionWithDecorator1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
var v = @decorate class C { static p = 1 };
33

44
//// [classExpressionWithDecorator1.js]
5-
var __decorate = this.__decorate || function (decorators, target, key, desc) {
5+
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) {
66
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
77
switch (arguments.length) {
88
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);

tests/baselines/reference/decoratedClassFromExternalModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default class Decorated { }
1010
import Decorated from 'decorated';
1111

1212
//// [decorated.js]
13-
var __decorate = this.__decorate || function (decorators, target, key, desc) {
13+
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) {
1414
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
1515
switch (arguments.length) {
1616
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);

tests/baselines/reference/decoratorOnClass1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class C {
66
}
77

88
//// [decoratorOnClass1.js]
9-
var __decorate = this.__decorate || function (decorators, target, key, desc) {
9+
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) {
1010
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
1111
switch (arguments.length) {
1212
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);

tests/baselines/reference/decoratorOnClass2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class C {
66
}
77

88
//// [decoratorOnClass2.js]
9-
var __decorate = this.__decorate || function (decorators, target, key, desc) {
9+
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) {
1010
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
1111
switch (arguments.length) {
1212
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);

tests/baselines/reference/decoratorOnClass3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class C {
77
}
88

99
//// [decoratorOnClass3.js]
10-
var __decorate = this.__decorate || function (decorators, target, key, desc) {
10+
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) {
1111
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
1212
switch (arguments.length) {
1313
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);

tests/baselines/reference/decoratorOnClass4.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class C {
66
}
77

88
//// [decoratorOnClass4.js]
9-
var __decorate = this.__decorate || function (decorators, target, key, desc) {
9+
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) {
1010
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
1111
switch (arguments.length) {
1212
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);

tests/baselines/reference/decoratorOnClass5.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class C {
66
}
77

88
//// [decoratorOnClass5.js]
9-
var __decorate = this.__decorate || function (decorators, target, key, desc) {
9+
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) {
1010
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
1111
switch (arguments.length) {
1212
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);

tests/baselines/reference/decoratorOnClass8.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class C {
66
}
77

88
//// [decoratorOnClass8.js]
9-
var __decorate = this.__decorate || function (decorators, target, key, desc) {
9+
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) {
1010
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
1111
switch (arguments.length) {
1212
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);

tests/baselines/reference/decoratorOnClassAccessor1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class C {
66
}
77

88
//// [decoratorOnClassAccessor1.js]
9-
var __decorate = this.__decorate || function (decorators, target, key, desc) {
9+
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) {
1010
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
1111
switch (arguments.length) {
1212
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);

0 commit comments

Comments
 (0)