babel / kneden

Transpile ES2017 async/await to vanilla ES6 Promise chains: a Babel plugin
ISC License
515 stars 41 forks source link

Doesn't work with es2015-classes #122

Open z-vr opened 7 years ago

z-vr commented 7 years ago
class Test {
    async test() {
        throw new Error('test-error');
    }
}
      AssertionError [ERR_ASSERTION]: '\'use strict\';\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length == 'class Test {\n    test() {\n        return Promise.resolve().then(function () {\n            throw new Error(\'test-error\');\n
      + expected - actual

      -'use strict';
      -
      -var _createClass = function () { function defineProperties(target, props) { for (var i = 0;i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
      -
      -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function"); } }
      -
      -var Test = function () {
      -    function Test() {
      -        _classCallCheck(this, Test);
      +class Test {
      +    test() {
      +        return Promise.resolve().then(function () {
      +            throw new Error('test-error');
      +        });
           }
      -
      -    _createClass(Test, [{
      -        key: 'test',
      -        value: function test() {
      -            throw new Error('test-error');
      -        }
      -    }]);
      -
      -    return Test;
      -}();
      +}

      at Context.<anonymous> (test/index.js:30:14)
loganfsmyth commented 7 years ago

Thanks for filing. Beware that this module is essentially unmaintained currently. Happy to leave this open, but it probably won't get fixed.

You may want to take a look at https://www.npmjs.com/package/fast-async