Skip to content

Commit ddf2ad4

Browse files
authored
Merge pull request microsoft#12247 from Microsoft/fix10840
Fix missing alias for decorated classes in es5
2 parents e50adc0 + bb21810 commit ddf2ad4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9936,8 +9936,7 @@ namespace ts {
99369936
// Due to the emit for class decorators, any reference to the class from inside of the class body
99379937
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
99389938
// behavior of class names in ES6.
9939-
if (languageVersion === ScriptTarget.ES2015
9940-
&& declaration.kind === SyntaxKind.ClassDeclaration
9939+
if (declaration.kind === SyntaxKind.ClassDeclaration
99419940
&& nodeIsDecorated(declaration)) {
99429941
let container = getContainingClass(node);
99439942
while (container !== undefined) {

tests/baselines/reference/es6modulekindWithES5Target11.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
1616
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1717
return c > 3 && r && Object.defineProperty(target, key, r), r;
1818
};
19-
var C = (function () {
19+
var C = C_1 = (function () {
2020
function C() {
2121
this.p = 1;
2222
}
23-
C.x = function () { return C.y; };
23+
C.x = function () { return C_1.y; };
2424
C.prototype.method = function () { };
2525
return C;
2626
}());
2727
C.y = 1;
28-
C = __decorate([
28+
C = C_1 = __decorate([
2929
foo
3030
], C);
3131
export default C;
32+
var C_1;

0 commit comments

Comments
 (0)