|
| 1 | +//// [tests/cases/compiler/parameterDecoratorsEmitCrash.ts] //// |
| 2 | + |
| 3 | +//// [parameterDecoratorsEmitCrash.ts] |
| 4 | +// https://github.com/microsoft/TypeScript/issues/58269 |
| 5 | +declare var dec: any; |
| 6 | + |
| 7 | +export class C { |
| 8 | + @dec x: any; |
| 9 | + constructor(@dec x: any) {} |
| 10 | +} |
| 11 | + |
| 12 | + |
| 13 | +//// [parameterDecoratorsEmitCrash.js] |
| 14 | +"use strict"; |
| 15 | +var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { |
| 16 | + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } |
| 17 | + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; |
| 18 | + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; |
| 19 | + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); |
| 20 | + var _, done = false; |
| 21 | + for (var i = decorators.length - 1; i >= 0; i--) { |
| 22 | + var context = {}; |
| 23 | + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; |
| 24 | + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; |
| 25 | + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; |
| 26 | + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); |
| 27 | + if (kind === "accessor") { |
| 28 | + if (result === void 0) continue; |
| 29 | + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); |
| 30 | + if (_ = accept(result.get)) descriptor.get = _; |
| 31 | + if (_ = accept(result.set)) descriptor.set = _; |
| 32 | + if (_ = accept(result.init)) initializers.unshift(_); |
| 33 | + } |
| 34 | + else if (_ = accept(result)) { |
| 35 | + if (kind === "field") initializers.unshift(_); |
| 36 | + else descriptor[key] = _; |
| 37 | + } |
| 38 | + } |
| 39 | + if (target) Object.defineProperty(target, contextIn.name, descriptor); |
| 40 | + done = true; |
| 41 | +}; |
| 42 | +var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { |
| 43 | + var useValue = arguments.length > 2; |
| 44 | + for (var i = 0; i < initializers.length; i++) { |
| 45 | + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); |
| 46 | + } |
| 47 | + return useValue ? value : void 0; |
| 48 | +}; |
| 49 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 50 | +exports.C = void 0; |
| 51 | +var C = function () { |
| 52 | + var _a; |
| 53 | + var _x_decorators; |
| 54 | + var _x_initializers = []; |
| 55 | + var _x_extraInitializers = []; |
| 56 | + return _a = /** @class */ (function () { |
| 57 | + function C(x) { |
| 58 | + this.x = __runInitializers(this, _x_initializers, void 0); |
| 59 | + __runInitializers(this, _x_extraInitializers); |
| 60 | + } |
| 61 | + return C; |
| 62 | + }()), |
| 63 | + (function () { |
| 64 | + var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; |
| 65 | + _x_decorators = [dec]; |
| 66 | + __esDecorate(null, null, _x_decorators, { kind: "field", name: "x", static: false, private: false, access: { has: function (obj) { return "x" in obj; }, get: function (obj) { return obj.x; }, set: function (obj, value) { obj.x = value; } }, metadata: _metadata }, _x_initializers, _x_extraInitializers); |
| 67 | + if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); |
| 68 | + })(), |
| 69 | + _a; |
| 70 | +}(); |
| 71 | +exports.C = C; |
0 commit comments