ember-codemods / es5-getter-ember-codemod

34 stars 14 forks source link

ObjectProxy usage of .get('id') should not be updated #33

Open rajveerappan opened 4 years ago

rajveerappan commented 4 years ago

Example:

import ObjectProxy from '@ember/object/proxy';
import { computed } from '@ember/object';

export default ObjectProxy.extend({
  isSelection: computed('id', 'selectionId', function () {
    return this.get('id') === this.selectionId;
  }),
});

Actual: Running this codemod updates usages of this.get('id') to this.id. However, in the case of an ObjectProxy it is still expected that access happens via this.get('id').

Changing to this.id throws the following error:

            Uncaught Error: Assertion Failed: You attempted to access the `id` property (of <(unknown):ember1010>).
            Since Ember 3.1, this is usually fine as you no longer need to use `.get()`
            to access computed properties. However, in this case, the object in question
            is a special kind of Ember object (a proxy). Therefore, it is still necessary
            to use `.get('id')` in this case.

            If you encountered this error because of third-party code that you don't control,
            there is more information at https://github.com/emberjs/ember.js/issues/16148, and
            you can help us improve this error message by telling us more about what happened in
            this situation.

Expected: Usages of this.get('id') within an ObjectProxy are ignored.