New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preset-env with async arrow function class properties produces broken code on Edge #8019
Comments
Hey @taion! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
As mentioned on Slack, sounds like chakra-core/ChakraCore#4663 so we may want to have a special case for class support on Edge or something to fall back to non-native classes. |
And for additional reference, I'm seeing this on the most recent Edge available on SauceLabs: Microsoft Edge 42.17134.1.0 |
is there any workaround for this? This looks like an easy fix, but the bug has a heavy impact. |
For now you could force classes to be transformed. |
Would transpiling to Or is the suggested fix to force classes to be transformed and wait for the ChakraCore fix to land? |
Checked with latest Babel (7.3.4) and it seems to be fixed. REPL link (you need to add Input: // Imagine this is a transpiled class.
function Foo() {}
class Bar extends Foo {
constructor() {
super();
}
bar = async () => {
console.log(this);
};
}
new Bar().bar(); Output: // Imagine this is a transpiled class.
function Foo() {}
class Bar extends Foo {
constructor() {
var _this;
super(); // important part is here
_this = this; // important part is here
_defineProperty(this, "bar",
// etc.
}
}
new Bar().bar(); As you can see, |
nice! |
This appears to have worked since 7.0.0, at least. Very nice. |
Bug Report
Current Behavior
See the code below. This code works as expected on Chrome (the instance of
Bar
) is logged, but it does not work on Edge. On Edge,undefined
is logged.This is because
super()
apparently returnsundefined
on Edge when the superclass is not actually an ES2015 class.In my example, this comes up in practice when I have things extending
React.Component
.Input Code
https://babeljs.io/repl/#?babili=false&browsers=Edge%3E%3D14%2C%20Chrome%20%3E%3D%2060&build=&builtIns=usage&code_lz=PTAEEkFsEMHMEsB2BTUAXAFvAzqHpp0AnaRbAB3gBtkATUAYyum2wDoAoAMwFdEG08APaJQAMSFCAFAEpQAbwC-HDkxa4AQtCKhkADzTJEtXBKEKOoRiOxoiPAUKKyLVq9h7lkzmQG5LoMoBXJKgALygLmEAfAqK_gEARtrhBNgAnvyRcjGubgw2QjRsVEKwUpg4fgHxHEEoAO6gWj5syT6-QA&debug=true&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=true&fileSize=false&lineWrap=false&presets=stage-2%2Cenv&prettier=false&targets=&version=6.26.0&envVersion=1.6.2
Expected behavior/code
A clear and concise description of what you expected to happen (or code).
Babel Configuration (.babelrc, package.json, cli command)
Per REPL.
Environment
Possible Solution
@loganfsmyth suggested transpiling to
(super(...), _this = this)
instead of_this = super(...)
.The text was updated successfully, but these errors were encountered: