-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Native classes cannot be extended by transpiled classes #9367
Comments
Hey @vzaidman! 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 |
I'll be glad to fix it with a PR of my own. Can I have a suggestion on how to do it, please? |
Actually there already is #8656! |
oh wow thanks |
@nicolo-ribaudo the PR is no longer compatible with master |
Keep running into this bug as well |
Thanks! My early version of preset-env: |
Fixed by #8656 |
@nicolo-ribaudo it looks like this is still an issue when loose mode is enabled, is that expected? Starting with the output from this repl, if I replace
|
It's because you are using |
Bug Report
Current Behavior
I'm building the library @welldone-software/why-did-you-render where I transpile the code:
Where
ClassComponent
is provided by the user.For the code transpiling I use
@babel/preset-env
with default target which means plugins are used includingbabel-plugin-transform-classes
.If a user provides a native class in case his app is transpiled for latest browsers without
babel-plugin-transform-classes
, the applicaiton fails with the error:Because transpiled classes are failing to extend native classes.
Expected behavior/code
Transpiled classes supports native classes extension.
Babel Config File (Simplified)
Environment
Possible Solution
Make the plugin check if the passed class to extend is a native one and if it is, use the native
extends
code or an equivalent one.Workarounds
For now, to help users who encounter this problem, I added 3 endpoints where classes are not transpiled:
by excluding the
babel-plugin-transform-classes
plugin:Other Relevant Suggestions
If we had an improved error message when calling a class as a function, this error would of been much easier to debug. The error
Class constructor model cannot be invoked without 'new'
is very unclear: #8948Related Issues
#4269
#6299
#7022
#7221
#8894
#9280
The text was updated successfully, but these errors were encountered: