fix exported classes with static class properties - fixes #2868

This commit is contained in:
Sebastian McKenzie
2015-11-10 15:56:22 -08:00
parent 29f756fd6f
commit 54c13eef5c
24 changed files with 24 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
var foo = "bar";
class Foo {
bar = foo;
constructor() {
var foo = "foo";
}
}

View File

@@ -0,0 +1,13 @@
var foo = "bar";
var Foo = function Foo() {
babelHelpers.classCallCheck(this, Foo);
_initialiseProps.call(this);
var foo = "foo";
};
var _initialiseProps = function () {
this.bar = foo;
};

View File

@@ -0,0 +1,3 @@
class Foo extends Bar {
bar = "foo";
}

View File

@@ -0,0 +1,12 @@
var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo(...args) {
var _temp, _this;
babelHelpers.classCallCheck(this, Foo);
return babelHelpers.possibleConstructorReturn(_this, (_temp = (_this = babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(Foo).call(this, ...args)), _this), _this.bar = "foo", _temp));
}
return Foo;
})(Bar);

View File

@@ -0,0 +1,3 @@
class Foo {
bar;
}

View File

@@ -0,0 +1,3 @@
var Foo = function Foo() {
babelHelpers.classCallCheck(this, Foo);
};

View File

@@ -0,0 +1,3 @@
class Foo {
bar = "foo";
}

View File

@@ -0,0 +1,4 @@
var Foo = function Foo() {
babelHelpers.classCallCheck(this, Foo);
this.bar = "foo";
};

View File

@@ -0,0 +1,3 @@
{
"plugins": ["external-helpers-2", "transform-class-properties", "transform-es2015-classes", "transform-es2015-block-scoping", "syntax-class-properties"]
}

View File

@@ -0,0 +1,7 @@
export class MyClass {
static property = value;
}
export default class MyClass2 {
static property = value;
}

View File

@@ -0,0 +1,12 @@
export var MyClass = function MyClass() {
babelHelpers.classCallCheck(this, MyClass);
};
MyClass.property = value;
var MyClass2 = function MyClass2() {
babelHelpers.classCallCheck(this, MyClass2);
};
export default MyClass2;
MyClass2.property = value;

View File

@@ -0,0 +1,3 @@
class Foo {
static bar;
}

View File

@@ -0,0 +1,6 @@
class Foo {
static num;
}
assert.equal("num" in Foo, false);
assert.equal(Foo.num, undefined);

View File

@@ -0,0 +1,3 @@
var Foo = function Foo() {
babelHelpers.classCallCheck(this, Foo);
};

View File

@@ -0,0 +1,3 @@
class Foo {
static bar = "foo";
}

View File

@@ -0,0 +1,9 @@
class Foo {
static num = 0;
static str = "foo";
}
assert.equal(Foo.num, 0);
assert.equal(Foo.num = 1, 1);
assert.equal(Foo.str, "foo");
assert.equal(Foo.str = "bar", "bar");

View File

@@ -0,0 +1,5 @@
var Foo = function Foo() {
babelHelpers.classCallCheck(this, Foo);
};
Foo.bar = "foo";

View File

@@ -0,0 +1,7 @@
class Foo extends Bar {
bar = "foo";
constructor() {
foo(super());
}
}

View File

@@ -0,0 +1,14 @@
var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _temp, _this;
babelHelpers.classCallCheck(this, Foo);
foo((_temp = (_this = babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(Foo).call(this)), _this), _this.bar = "foo", _temp));
return _this;
}
return Foo;
})(Bar);

View File

@@ -0,0 +1,7 @@
class Foo extends Bar {
bar = "foo";
constructor() {
super();
}
}

View File

@@ -0,0 +1,14 @@
var Foo = (function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() {
babelHelpers.classCallCheck(this, Foo);
var _this = babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(Foo).call(this));
_this.bar = "foo";
return _this;
}
return Foo;
})(Bar);