-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Extending from native classes #17042
Comments
Is this the same as https://discuss.emberjs.com/t/ember-3-2-ember-decorators-subclassing-bug/15380? We also hit that issue. |
Yes, it is the same issue. |
@rwjblue - is there any timeframe on fixing this? Do you have any idea where the problem might be? Because we've been hitting this a lot when using native classes in TypeScript (and using the language with |
If you create a patched version extend in your app so that babel compiles it according to your App settings. import EmberObject from "@ember/object";
EmberObject.extend = function (...args) {
class Class extends this;
Class.reopen(...args);
return Class;
}
export default EmberObject; then import from that in your app it should workaround the problem until we publish the es so that ember-cli compiles ember with the same babel settings. |
@krisselden - thank you for the suggested workaround! For any future readers, the |
This is fixed in the current release, so I'm going to go ahead and close... |
@rwjblue - this is still not fixed for me on 3.6.1. Getting the same error as in the first post of this issue. I think this should be reopened. Or am I missing something? |
Happy to reopen with a demo repo |
Just in case anybody is wondering about the ember-twiddle tests which I had posted in the OP, those are wrong... I had incorrectly mixed the properties on the class prototype (.extend) and class instance (native class properties). 3.6.1 is working fine, though. |
@rwjblue - here is a reproduction. It took me a while but it was quite simple in the end - it's because of the |
@rwjblue - ping. :) Did you manage to take a look at the reproduction? Let's reopen the issue so we don't forget it. :) |
Yes, I did but I’m not sure we can/should reopen. Sorry, I’m out with the family at the moment but will try to explain once I’m back at a keyboard... |
@rwjblue - I don't want to be annoying, but could you please explain why you don't think this is a bug? :) Thanks! |
@rwjblue - after updating Also, if you could explain why adding |
I've pushed a commit in my reproduction repo that showcases the latest problem. Both issues can be seen in it - |
I have the same issue after upgrade of dependencies in my repo. Upgrade of direct dependencies was OK but after removing yarn.lock and generating new one - minor upgrades took place in indirect dependencies (i.e. dependencies of dependencies). E.g. Error which I have: Details with generated code AFTER upgradePart of the stack trace (from generated code):
and generated Class definiton which extends
generated
In the code we crate new instance of Details with generated code BEFORE upgradeOnly difference is in vendor (CoreObject): ``` static extend() { let Class = class extends this {}; reopen.apply(Class.PrototypeMixin, arguments); return Class; } ``` |
@Krzyrok - I opened another issue for that. They fixed it, we're waiting for the new version to fix it. :) |
Great! Thanks for link :) |
For surfers who face this bug on Ember upgrade 3.1 -> 3.2, exactly as mentioned here: // ember-cli-build.js
let app = new EmberApp(defaults, {
// ...
babel: {
include: [
'transform-classes',
],
},
// ... |
Follow up of
ember-decorators/ember-decorators#115 (comment)
and new issue here, as requested by @rwjblue
Extending a native class with
.extend
which itself is extending EmberObject is throwing aThe motivation of this is being able to use native classes and mixins, like this:
See this ember-twiddle:
https://canary.ember-twiddle.com/b365ecfbc29444455d082cf1b295156b?openFiles=tests.foo-test.js%2C
The text was updated successfully, but these errors were encountered: