-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
Multiple computed properties with decorators fail using 1.5.0-alpha:
declare function decorate();
class Foo {
@decorate
["name-1"]() {}
@decorate
["name-2"]() {}
}Compiles to
var Foo = (function () {
function Foo() {
}
Foo.prototype[_a = "name-1"] = function () { };
Foo.prototype[_a] = function () { };
Object.defineProperty(Foo.prototype, _a, __decorate([decorate], Foo.prototype, _a, Object.getOwnPropertyDescriptor(Foo.prototype, _a)));
Object.defineProperty(Foo.prototype, _a, __decorate([decorate], Foo.prototype, _a, Object.getOwnPropertyDescriptor(Foo.prototype, _a)));
return Foo;
var _a;
})();Note that both methods use temporary variable _a and only "name-1" is emitted in the javascript. The result should be:
var Foo = (function () {
function Foo() {
}
Foo.prototype[_a = "name-1"] = function () { };
Foo.prototype[_b = "name-2"] = function () { };
Object.defineProperty(Foo.prototype, _a, __decorate([decorate], Foo.prototype, _a, Object.getOwnPropertyDescriptor(Foo.prototype, _a)));
Object.defineProperty(Foo.prototype, _b, __decorate([decorate], Foo.prototype, _b, Object.getOwnPropertyDescriptor(Foo.prototype, _b)));
return Foo;
var _a, _b;
})();Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue