Merge pull request #1256 from jayphelps/fix-writable

class properties with an undefined value are now correctly writable
This commit is contained in:
Sebastian McKenzie 2015-04-13 21:52:46 -07:00
commit 3b189e22b7
6 changed files with 45 additions and 0 deletions

View File

@ -552,6 +552,11 @@ class ClassTransformer {
this.instancePropBody.push(t.expressionStatement(
t.assignmentExpression("=", t.memberExpression(t.thisExpression(), node.key), node.value)
));
node.value = null;
}
if (!node.value) {
node.value = t.identifier("undefined");
}

View File

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

View File

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

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, true);
assert.equal(Foo.num, undefined);

View File

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