emberjs/ember-classic-decorator

Unable to extend `HistoryLocation` as a native class

mehulkar opened this issue · 4 comments

We have a custom location class that extends HistoryLocation from Ember. Looks like it throws this error, even though the extended class does not add its own constructor or init methods.

Error: You defined the class location with a 'constructor' function, but one of its ancestors, DebugFrameworkObject, uses the 'init' method. Due to the timing of the constructor and init methods, its not generally safe to use 'constructor' for class setup if the parent class is using 'init'. You can mark location with the @classic decorator and safely use 'init', or you can convert the parent class to use native classes, and switch from 'init' to 'constructor' there first.

#27 should have fixed this afaik, but I'm using ember-classic-decorator 1.0.5 and still seeing the same output.

Full stack trace:

Error: You defined the class location with a 'constructor' function, but one of its ancestors, DebugFrameworkObject, uses the 'init' method. Due to the timing of the constructor and init methods, its not generally safe to use 'constructor' for class setup if the parent class is using 'init'. You can mark location with the @classic decorator and safely use 'init', or you can convert the parent class to use native classes, and switch from 'init' to 'constructor' there first.

If this error message is not being triggered by your code or code from an addon, but from Ember itself, please file a bug report on the classic decorator repo: https://github.com/emberjs/ember-classic-decorator
    at Function.create (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/vendor/classic-decorator/index.js:88:1)
    at Function.superWrapper [as create] (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/utils/index.js:367:1)
    at FactoryManager.create (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/container/index.js:552:1)
    at instantiateFactory (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/container/index.js:362:1)
    at lookup (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/container/index.js:290:1)
    at Container.lookup (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/container/index.js:134:1)
    at Class.lookup (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/runtime/lib/mixins/container_proxy.js:81:1)
    at IndexRoute.getInjection (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/metal/index.js:5048:1)
    at untrack (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/metal/index.js:3327:1)
    at untrack (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/metal/index.js:1247:1)
    at ComputedProperty.get (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/metal/index.js:3326:1)
    at IndexRoute.location (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/metal/index.js:1044:1)
    at IndexRoute.model (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/web-tv-app/routes/index.js:65:18)
    at IndexRoute.deserialize (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/@ember/-internals/routing/lib/system/route.js:1040:1)
    at UnresolvedRouteInfoByParam.getModel (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/router_js.js:895:1)
    at _rsvp.Promise.resolve.then.then.then.then (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/router_js.js:691:1)
    at invokeCallback (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/rsvp.js:493:1)
    at publish (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/rsvp.js:476:1)
    at _runloop.backburner.schedule (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/ember-testing/lib/ext/rsvp.js:19:1)
    at invokeWithOnError (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/backburner.js:347:1)
    at Queue.flush (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/backburner.js:229:1)
    at DeferredActionQueues.flush (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/backburner.js:426:1)
    at Backburner._end (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/backburner.js:960:1)
    at Backburner._boundAutorunEnd (/var/folders/bf/vg2wsvj91vq9kjmyjflpy_880000gn/T/broccoli-38360tW4NsU2YJuXR/out-504-broccoli_merge_trees/assets/backburner.js:629:1)
    at process._tickCallback (internal/process/next_tick.js:68:7)

I can repro this even if I don't use my extended class

Most likely becuase Ember.Location is not a thing. HistoryLocation extends from Ember.Object directly

https://github.com/emberjs/ember.js/blob/master/packages/@ember/-internals/routing/lib/location/history_location.ts#L51