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