Merge pull request #1256 from jayphelps/fix-writable
class properties with an undefined value are now correctly writable
This commit is contained in:
commit
3b189e22b7
@ -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");
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
bar;
|
||||
}
|
||||
@ -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;
|
||||
})();
|
||||
@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
static bar;
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
class Foo {
|
||||
static num;
|
||||
}
|
||||
|
||||
assert.equal("num" in Foo, true);
|
||||
assert.equal(Foo.num, undefined);
|
||||
@ -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;
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user