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
Current Behavior
Using @babel/preset-env, target ie: 11.
When a class extends Array indirectly, all the methods disappears.
Input Code
functionClassFactory(superObj){classClassTemplateextendssuperObj{constructor(){super([1,2]);this.k=1;returnthis;}test(){console.log(this.k);}}returnClassTemplate;}classUsefulClassextendsClassFactory(Array){constructor(){super();this.j=1;returnthis;}test2(){console.log(this.j);}}constinstance=newUsefulClass();instance.test();// Uncaught TypeError: p.test is not a functioninstance.test2();console.log(instance);
Possible Solution
I noticed if a class directly extends Array, it will become _wrapNativeSuper(Array), but in my case, there're no _wrapNativeSuper. I believe it's the cause of the issue. I think babel could do this check when a variable is possibly a native class. Like:
Hey @herbix! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.
ClassFactory(class extends Array {}) is a great idea. But sample codes are from another library that I can't edit tem. I had to write a loader to do this trick.
I mean, when a class extends another class from variables or arguments, the super class might be Array. Should babel check whether it needs a _wrapNativeSuper first?
Bug Report
Current Behavior
Using @babel/preset-env, target ie: 11.
When a class extends Array indirectly, all the methods disappears.
Input Code
Expected behavior/code
The methods should exist.
Babel Configuration (.babelrc, package.json, cli command)
In
webpack.config.json
:In
package.json
:Environment
Possible Solution
I noticed if a class directly extends
Array
, it will become_wrapNativeSuper(Array)
, but in my case, there're no_wrapNativeSuper
. I believe it's the cause of the issue. I think babel could do this check when a variable is possibly a native class. Like:Additional context/Screenshots
Nop.
The text was updated successfully, but these errors were encountered: