Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
babel-transform-legacy-decorators v1.3.0 bug
import autobind from './autobind';
class Base {
constructor(v) {
this.v = v;
}
}
function multiply(by) {
return function $multiply(target, name, descriptor) {
return {
...descriptor,
value(...args) {
return by * Reflect.apply(descriptor.value, this, args);
},
};
};
}
const FIVE = 5;
const SEVEN = 7;
@autobind
class Complex extends Base {
@multiply(SEVEN)
static multiplyByFortyFive(v) {
return FIVE * v;
}
@multiply(1 / SEVEN)
multiplyByFortyFive() {
return SEVEN * this.constructor.multiplyByFortyFive(this.v);
}
}
const x = Complex;
export default x;
'use strict';
var _dec, _dec2, _class, _desc, _value, _class2;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _getOwnPropertyDescriptor = require('babel-runtime/core-js/object/get-own-property-descriptor');
var _getOwnPropertyDescriptor2 = _interopRequireDefault(_getOwnPropertyDescriptor);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _apply = require('babel-runtime/core-js/reflect/apply');
var _apply2 = _interopRequireDefault(_apply);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _autobind = require('./autobind');
var _autobind2 = _interopRequireDefault(_autobind);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
let Base = function Base(v) {
(0, _classCallCheck3.default)(this, Base);
this.v = v;
};
function multiply(by) {
return function $multiply(target, name, descriptor) {
return (0, _extends3.default)({}, descriptor, {
value: function value() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return by * (0, _apply2.default)(descriptor.value, this, args);
}
});
};
}
const FIVE = 5;
const SEVEN = 7;
let Complex = (_dec = multiply(SEVEN), _dec2 = multiply(1 / SEVEN), (0, _autobind2.default)(_class = (_class2 = (function (_Base) {
(0, _inherits3.default)(Complex, _Base);
function Complex() {
(0, _classCallCheck3.default)(this, Complex);
return (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(Complex).apply(this, arguments));
}
(0, _createClass3.default)(Complex, [{
key: 'multiplyByFortyFive',
value: function multiplyByFortyFive() {
return SEVEN * this.constructor.multiplyByFortyFive(this.v);
}
}], [{
key: 'multiplyByFortyFive',
value: function multiplyByFortyFive(v) {
return FIVE * v;
}
}]);
return Complex;
})(Base), (_desc = _dec(_class2, 'multiplyByFortyFive', _desc = (0, _getOwnPropertyDescriptor2.default)(_class2, 'multiplyByFortyFive')) || _desc, _desc ? Object.defineProperty(_class2, 'multiplyByFortyFive', _desc) : void 0, _desc = _dec2(_class2.prototype, 'multiplyByFortyFive', _desc = (0, _getOwnPropertyDescriptor2.default)(_class2.prototype, 'multiplyByFortyFive')) || _desc, _desc ? Object.defineProperty(_class2.prototype, 'multiplyByFortyFive', _desc) : void 0), _class2)) || _class);
const x = Complex;
exports.default = x;
'use strict';
import _Object$defineProperty from 'babel-runtime/core-js/object/define-property';
var _dec, _dec2, _class, _desc, _value, _class2;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _getOwnPropertyDescriptor = require('babel-runtime/core-js/object/get-own-property-descriptor');
var _getOwnPropertyDescriptor2 = _interopRequireDefault(_getOwnPropertyDescriptor);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _apply = require('babel-runtime/core-js/reflect/apply');
var _apply2 = _interopRequireDefault(_apply);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _autobind = require('./autobind');
var _autobind2 = _interopRequireDefault(_autobind);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
let desc = {
enumerable: !!descriptor.enumerable,
configurable: !!descriptor.configurable
};
if ('value' in descriptor || 'initializer' in descriptor) {
desc.writable = true;
desc.initializer = descriptor.initializer;
desc.value = descriptor.value;
} else {
desc.get = descriptor.get;
desc.set = descriptor.set;
}
desc = decorators.slice().reverse().reduce(function (desc, decorator) {
return decorator(target, property, desc) || desc;
}, desc);
if (context && desc.initializer !== void 0) {
desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
desc.initializer = void 0;
}
if (desc.initializer === void 0) {
_Object$defineProperty(target, property, desc);
desc = null;
}
return desc;
}
let Base = function Base(v) {
(0, _classCallCheck3.default)(this, Base);
this.v = v;
};
function multiply(by) {
return function $multiply(target, name, descriptor) {
return (0, _extends3.default)({}, descriptor, {
value: function value() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return by * (0, _apply2.default)(descriptor.value, this, args);
}
});
};
}
const FIVE = 5;
const SEVEN = 7;
let Complex = (_dec = multiply(SEVEN), _dec2 = multiply(1 / SEVEN), (0, _autobind2.default)(_class = (_class2 = (function (_Base) {
(0, _inherits3.default)(Complex, _Base);
function Complex() {
(0, _classCallCheck3.default)(this, Complex);
return (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(Complex).apply(this, arguments));
}
(0, _createClass3.default)(Complex, [{
key: 'multiplyByFortyFive',
value: function multiplyByFortyFive() {
return SEVEN * this.constructor.multiplyByFortyFive(this.v);
}
}], [{
key: 'multiplyByFortyFive',
value: function multiplyByFortyFive(v) {
return FIVE * v;
}
}]);
return Complex;
})(Base), (_applyDecoratedDescriptor(_class2, 'multiplyByFortyFive', [_dec], (0, _getOwnPropertyDescriptor2.default)(_class2, 'multiplyByFortyFive'), _class2), _applyDecoratedDescriptor(_class2.prototype, 'multiplyByFortyFive', [_dec2], (0, _getOwnPropertyDescriptor2.default)(_class2.prototype, 'multiplyByFortyFive'), _class2.prototype)), _class2)) || _class);
const x = Complex;
exports.default = x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment