fbjs
fbjs copied to clipboard
[preset] Does not correctly transform arrow functions in property initializers
The babel preset currently doesn't seem to correctly transform arrow functions as class properties:
class Foo {
boundMethod = () => {
return this;
}
}
Output is this (note that _this is set to undefined instead of the instance).
"use strict";
var _this = undefined;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Foo = function Foo() {
_classCallCheck(this, Foo);
this.boundMethod = function () {
return _this;
};
};
Code for repro: https://gist.github.com/kassens/ee845ea5db4a24a8127ecbb1390b63cf
Related Babel task: https://phabricator.babeljs.io/T7274