fix decorator interop - fixes #1277

This commit is contained in:
Sebastian McKenzie
2015-04-25 18:18:30 +01:00
parent 00c0a958db
commit deed48a3db
22 changed files with 124 additions and 81 deletions

View File

@@ -12,14 +12,10 @@ var Foo = (function () {
}
babelHelpers.createClass(Foo, [{
key: "bar",
value: undefined,
enumerable: true
}, {
key: "__initializeProperties",
value: function __initializeProperties() {
this.bar = foo;
}
}]);
return Foo;
})();
})();

View File

@@ -12,10 +12,5 @@ var Foo = (function (_Bar) {
}
babelHelpers.inherits(Foo, _Bar);
babelHelpers.createClass(Foo, [{
key: "bar",
value: undefined,
enumerable: true
}]);
return Foo;
})(Bar);
})(Bar);

View File

@@ -1,14 +1,6 @@
"use strict";
var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}
babelHelpers.createClass(Foo, [{
key: "bar",
value: undefined,
enumerable: true
}]);
return Foo;
})();
var Foo = function Foo() {
babelHelpers.classCallCheck(this, Foo);
this.bar = undefined;
};

View File

@@ -1,15 +1,6 @@
"use strict";
var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
this.bar = "foo";
}
babelHelpers.createClass(Foo, [{
key: "bar",
value: undefined,
enumerable: true
}]);
return Foo;
})();
var Foo = function Foo() {
babelHelpers.classCallCheck(this, Foo);
this.bar = "foo";
};

View File

@@ -10,10 +10,5 @@ var Foo = (function (_Bar) {
}
babelHelpers.inherits(Foo, _Bar);
babelHelpers.createClass(Foo, [{
key: "bar",
value: undefined,
enumerable: true
}]);
return Foo;
})(Bar);

View File

@@ -9,10 +9,5 @@ var Foo = (function (_Bar) {
}
babelHelpers.inherits(Foo, _Bar);
babelHelpers.createClass(Foo, [{
key: "bar",
value: undefined,
enumerable: true
}]);
return Foo;
})(Bar);

View File

@@ -0,0 +1,14 @@
function noop() {}
class Foo {
@noop
bar = "foobar";
@noop
foo() {
return "bar";
}
}
assert.equal(new Foo().bar, "foobar");
assert.equal(new Foo().foo(), "bar");

View File

@@ -5,7 +5,7 @@ var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
this.foo = _instanceInitializers.foo.call(this);
babelHelpers.defineDecoratedPropertyDescriptor(this, "foo", _instanceInitializers);
}
babelHelpers.createDecoratedClass(Foo, [{
@@ -17,4 +17,4 @@ var Foo = (function () {
enumerable: true
}], null, _instanceInitializers);
return Foo;
})();
})();

View File

@@ -0,0 +1,14 @@
function noop() {}
class Foo {
@noop
static bar = "foobar";
@noop
static foo() {
return "bar";
}
}
assert.equal(Foo.bar, "foobar");
assert.equal(Foo.foo(), "bar");

View File

@@ -15,6 +15,6 @@ var Foo = (function () {
},
enumerable: true
}], null, _staticInitializers);
Foo.foo = _staticInitializers.foo.call(Foo);
babelHelpers.defineDecoratedPropertyDescriptor(Foo, "foo", _staticInitializers);
return Foo;
})();
})();

View File

@@ -5,7 +5,7 @@ var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
this.foo = _instanceInitializers.foo.call(this);
babelHelpers.defineDecoratedPropertyDescriptor(this, "foo", _instanceInitializers);
}
babelHelpers.createDecoratedClass(Foo, [{
@@ -15,4 +15,4 @@ var Foo = (function () {
enumerable: true
}], null, _instanceInitializers);
return Foo;
})();
})();

View File

@@ -13,6 +13,6 @@ var Foo = (function () {
initializer: function () {},
enumerable: true
}], null, _staticInitializers);
Foo.foo = _staticInitializers.foo.call(Foo);
babelHelpers.defineDecoratedPropertyDescriptor(Foo, "foo", _staticInitializers);
return Foo;
})();

View File

@@ -0,0 +1,15 @@
function override(target, key, descriptor) {
descriptor.initializer = function () {
return "lol";
};
}
var obj = {
@override
foo: "bar",
bar: "heh"
};
assert.equal(obj.foo, "lol");
assert.equal(obj.bar, "heh");

View File

@@ -3,12 +3,18 @@
var obj = babelHelpers.createDecoratedObject([{
key: "bar",
decorators: [foo],
value: function value() {}
initializer: function initializer() {
return function () {};
}
}, {
key: "foo",
decorators: [bar],
value: "lol"
initializer: function initializer() {
return "lol";
}
}, {
key: "yes",
value: "wow"
}]);
initializer: function initializer() {
return "wow";
}
}]);