Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Babel es7 decorators createDecoratedClass helper fails #69

Closed
offirgolan opened this issue Feb 23, 2016 · 1 comment
Closed

Babel es7 decorators createDecoratedClass helper fails #69

offirgolan opened this issue Feb 23, 2016 · 1 comment
Labels

Comments

@offirgolan
Copy link

Error while processing route: index Cannot set property 'foo' of undefined TypeError: Cannot set property 'foo' of undefined
    at defineProperties (http://localhost:4200/assets/vendor.js:156343:31)
    at http://localhost:4200/assets/vendor.js:156348:23
    at http://localhost:4200/assets/vendor.js:156502:5

Failure is coming from

defineProperties(Constructor.prototype, protoProps, protoInitializers) // protoInitializers === undefined

// ... inside defineProperties

if (descriptor.initializer !== undefined) {
  initializers[key] = descriptor;continue; // ERROR: Cannot set property 'foo' of undefined
}
var _createDecoratedClass = (function () {
    function defineProperties(target, descriptors, initializers) {
      for (var i = 0; i < descriptors.length; i++) {
        var descriptor = descriptors[i];var decorators = descriptor.decorators;var key = descriptor.key;delete descriptor.key;delete descriptor.decorators;descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ('value' in descriptor || descriptor.initializer) descriptor.writable = true;if (decorators) {
          for (var f = 0; f < decorators.length; f++) {
            var decorator = decorators[f];if (typeof decorator === 'function') {
              descriptor = decorator(target, key, descriptor) || descriptor;
            } else {
              throw new TypeError('The decorator for method ' + descriptor.key + ' is of the invalid type ' + typeof decorator);
            }
          }if (descriptor.initializer !== undefined) {
            initializers[key] = descriptor;continue;
          }
        }Object.defineProperty(target, key, descriptor);
      }
    }return function (Constructor, protoProps, staticProps, protoInitializers, staticInitializers) {
      if (protoProps) defineProperties(Constructor.prototype, protoProps, protoInitializers);if (staticProps) defineProperties(Constructor, staticProps, staticInitializers);return Constructor;
    };
  })();

Tests for this can be found here: ember-decorators/ember-decorators/pull/61

Seems like a Babel issue which might have been fixed in later versions. Might need to up babel-core but not too sure.

@rwjblue
Copy link
Member

rwjblue commented Jul 5, 2017

I believe this is fixed with the babel@6 updates (will continue to follow up in https://github.com/rwjblue/ember-decorators/pull/61).

@rwjblue rwjblue closed this as completed Jul 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants