2

I was on Ember version 2.16 and we upgraded to 3.8. After version upgrade I am seeing this error but not able to figure out from where the error is coming. In what scenarios will I get this error. I saw one of the post:

Dynamic computed properties in Ember.JS deprecated?

But couldn't figure out the same in my code.

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Shreya Shah
  • 582
  • 1
  • 4
  • 17
  • Readers will probably need to see the piece of your code that creates this error. Would you add it to your post? – halfer Jun 14 '19 at 07:35
  • You might need to upgrade another package (rather than your code). For me, I had to upgrade the `ember-cp-validations` package to `^4.0.0` – Rami Alloush Dec 05 '22 at 19:15

1 Answers1

4

I guess you didn't upgrade step by step but moved from 2.18 to 3.8 directly, did you? In 3.2 a deprecation was added that computed properties must be defined using defineProperty if object is already created. The functionality was removed in 3.5. Setting a computed property dynamically using set or a property on an object passed to EmberObject.create() is not supported anymore.

This has been deprecated in 3.2 and removed in 3.5:

import Object as EmberObject, { computed } from '@ember/object';

EmberObject.create({
  foo: computed('bar', function() {
    // ...
  })
});
EmberObject.extend({
  init() {
    this._super(...arguments);

    this.set('foo', computed('bar', function() {
      //  ...
    }));
  }
});

You should migrate to:

import Object as EmberObject, { computed } from '@ember/object';

EmberObject.extend({
  foo: computed('bar', function() {
    // ...
  })
}).create();
import { defineProperty } from '@ember/object';

EmberObject.extend({
  init() {
    this._super(...arguments);

    defineProperty(this, 'foo', computed('bar', function() {
      //  ...
    }));
  }
});

This old syntax wasn't a public API. While Ember does not introduce breaking changes to public API, private APIs may be changed at any time. If core team considers them as widely used, they are deprecated and removed after next LTS release. This was the case here.

Normally it's safer and easier to do a step to step upgrade from LTS to LTS. In that case you don't miss helpful deprecation messages.

Please also have a look into the entry in deprecation guide even so it's a little bit to technical and should have had more real world examples in my opinion.

jelhan
  • 6,149
  • 1
  • 19
  • 35