mardi 16 mai 2017

attributes are not defined with babel 6

I have an Ember app with ember-computed-decorators and I have this kind of model :

import DS from 'ember-data';
import {alias} from 'ember-computed-decorators';

export default DS.Model.extend({
  @alias('customData.email') email
});

It worked with ember-cli-babel version 5 but I updated to the version 6 with tranform-decorator-legacy and I have this error :

email is not defined

I reproduced it with a simple js script like this :

function dec(target, name, descriptor) {
  const method = descriptor.value;

  descriptor.value = function(...args) {
    return 'hello';
  }
}

const Foo = {
  @dec test
}

console.log(Foo.test);

And I have the same error.

This works :

function dec(target, name, descriptor) {
  const method = descriptor.value;

  descriptor.value = function(...args) {
    return 'hello';
  }
}

const Foo = {
  @dec
  test() {
    return 'test';
  }
}

console.log(Foo.test());

I think @dec test is strange but it worked with babel 5. What's the solution ?




Aucun commentaire:

Enregistrer un commentaire