You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for all of the work on this awesome plugin! I came across an instance where the plugin, when combined with @babel/preset-env, generates some invalid code.
Original code:
classA{asynca(x=this.x()){}}
The issue is that the line that applies the default arg references _this but appears outside of the scope where _this is defined.
Generated code:
"use strict";function_instanceof(left,right){if(right!=null&&typeofSymbol!=="undefined"&&right[Symbol.hasInstance]){returnright[Symbol.hasInstance](left);}else{returnleftinstanceofright;}}function_classCallCheck(instance,Constructor){if(!_instanceof(instance,Constructor)){thrownewTypeError("Cannot call a class as a function");}}function_defineProperties(target,props){for(vari=0;i<props.length;i++){vardescriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"indescriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function_createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);returnConstructor;}varA=/*#__PURE__*/function(){functionA(){_classCallCheck(this,A);}_createClass(A,[{key: "a",value: function(){varx=arguments.length>0&&arguments[0]!==undefined ? arguments[0] : _this.x();returnfunction(){var_this=this;}.apply(this);}}]);returnA;}();
Thanks for all of the work on this awesome plugin! I came across an instance where the plugin, when combined with
@babel/preset-env
, generates some invalid code.Original code:
The issue is that the line that applies the default arg references
_this
but appears outside of the scope where_this
is defined.Generated code:
Heres' my Babel config:
Here it is on the Babel REPL.
And some version info:
node
: 8.11.1@babel/core
: 7.3.3@babel/preset-env
: 7.3.1babel-plugin-transform-async-to-promises
: 0.8.5The text was updated successfully, but these errors were encountered: