mirror of
https://github.com/swc-project/swc.git
synced 2024-12-18 19:21:33 +03:00
2e29d78281
swc_ecma_transforms: - Emit proper typename for `design:type` used with enum. (#1160)
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
"use strict";
|
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
|
|
var desc = {
|
|
};
|
|
Object.keys(descriptor).forEach(function(key) {
|
|
desc[key] = descriptor[key];
|
|
});
|
|
desc.enumerable = !!desc.enumerable;
|
|
desc.configurable = !!desc.configurable;
|
|
if ("value" in desc || desc.initializer) {
|
|
desc.writable = true;
|
|
}
|
|
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 = undefined;
|
|
}
|
|
if (desc.initializer === void 0) {
|
|
Object.defineProperty(target, property, desc);
|
|
desc = null;
|
|
}
|
|
return desc;
|
|
}
|
|
function _initializerDefineProperty(target, property, descriptor, context) {
|
|
if (!descriptor) return;
|
|
Object.defineProperty(target, property, {
|
|
enumerable: descriptor.enumerable,
|
|
configurable: descriptor.configurable,
|
|
writable: descriptor.writable,
|
|
value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
|
|
});
|
|
}
|
|
var _class, _descriptor;
|
|
var MyEnum;
|
|
(function(MyEnum1) {
|
|
MyEnum1["x"] = "xxx";
|
|
MyEnum1["y"] = "yyy";
|
|
})(MyEnum || (MyEnum = {
|
|
}));
|
|
var _dec = Decorator(), _dec1 = typeof Reflect !== "undefined" && typeof Reflect.metadata === "function" && Reflect.metadata("design:type", String);
|
|
let Xpto = ((_class = function() {
|
|
class Xpto1 {
|
|
constructor(){
|
|
_initializerDefineProperty(this, "value", _descriptor, this);
|
|
}
|
|
}
|
|
return Xpto1;
|
|
}()) || _class, _descriptor = _applyDecoratedDescriptor(_class.prototype, "value", [
|
|
_dec,
|
|
_dec1
|
|
], {
|
|
configurable: true,
|
|
enumerable: true,
|
|
writable: true,
|
|
initializer: void 0
|
|
}), _class);
|
|
function Decorator() {
|
|
return function(...args) {
|
|
};
|
|
}
|