Errors when attempting to create a native class extending from Ability
Hi there! I've run into a few cases where I receive the following error while attempting to upgrade to using native classes that extend from Ability:
global failure: Error: You defined the class ExampleAbility that extends from Ember.Object using native class syntax, but you didn't mark it with the @classic decorator. All user classes that extend from this class must be marked as @classic, since they use classic features. If you want to remove the @classic decorator, you must remove the base class. For components, you can do this by converting to Glimmer components. For plain classes that extend from EmberObject, you can convert them into plain native classes that do not extend from EmberObject. If this class is a base class provided by the framework that you should be allowed to remove @classic from, please open an issue on the classic decorators repo: https://github.com/emberjs/ember-classic-decorator
One scenario I've been able to track down that has seemed to cause this is:
- Having a native class
Athat extends fromAbility - Having a component
Bthat uses acanhelper forAin its handlebars - Having a component
Cthat wraps componentB(think of something likeCbeing a dropdown andBbeing an item for example) - Having a tracked property within component
C
Removing the @tracked annotation from the property from component C in that scenario will allow for extending from Ability with no issues. I can work on trying to get a minimal reproducer if that is helpful here.
I've noticed that https://github.com/minutebase/ember-can/pull/151 removes the dependency on EmberObject from Ability which I imagine should resolve this issue without requiring the @classic decorator. Is this pull request still being actively worked on? Would be great to be able to use native class syntax without requiring the decorator.
Thanks in advance for the help. Let me know if I can provide any further information!
Hi Mario :) Yes, this PR should solve it, but I am not sure when I will have time to finish it. It was just a vision.
For know I would recommend to use classic decorator to solve this warning.
Gotcha, thank you for the confirmation Maciej! Will use the decorator in that case.