@bartocc wrote:
While migrating a 3.1.4 project to 3.2, I ran into the following error:
Class constructor A cannot be invoked without 'new'
.The project has 2 models, A and B, defined with ES6
class/extends
syntax thanks toember-decorators
.// models/a.js import DS from 'ember-data'; export default class A extends DS.Model { }
// models/b.js import A from './a'; // I need A.extend() here for polymorphic relationship reasons export default class B extends A.extend() { }
This code works under 3.1.4 but fails under 3.2 and I do not understand why.
The workaround I’ve found is to define A with EmberObject.extend() instead of using ES6 class syntax.
// models/a.js import DS from 'ember-data'; // this works under 3.1 and 3.2 export default DS.Model.extend({});
Another way to fix the issue is to define B like this
// models/b.js import A from './a'; // no more A.extend(), so no more bug, but it does not fit my needs. export default class B extends A { }
I’ve setup a repo to reproduce the bug:
I’d love to understand what’s going on here and how I could migrate to 3.2 without refactoring A to use EmberObject.extend
Posts: 1
Participants: 1