|
| 1 | +//// [tests/cases/conformance/esDecorators/classDeclaration/esDecorators-classDeclaration-staticName.ts] //// |
| 2 | + |
| 3 | +//// [esDecorators-classDeclaration-staticName.ts] |
| 4 | +declare let dec: any; |
| 5 | + |
| 6 | +@dec class A { |
| 7 | + static get name() { return 123; } |
| 8 | +} |
| 9 | + |
| 10 | +@dec class B { |
| 11 | + static name() { return 456; } |
| 12 | +} |
| 13 | + |
| 14 | +var C = @dec class { |
| 15 | + static get name() { return 789; } |
| 16 | +}; |
| 17 | + |
| 18 | +@dec class D {} |
| 19 | + |
| 20 | +@dec class E { |
| 21 | + static name = "custom"; |
| 22 | +} |
| 23 | + |
| 24 | + |
| 25 | +//// [esDecorators-classDeclaration-staticName.js] |
| 26 | +var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { |
| 27 | + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } |
| 28 | + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; |
| 29 | + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; |
| 30 | + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); |
| 31 | + var _, done = false; |
| 32 | + for (var i = decorators.length - 1; i >= 0; i--) { |
| 33 | + var context = {}; |
| 34 | + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; |
| 35 | + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; |
| 36 | + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; |
| 37 | + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); |
| 38 | + if (kind === "accessor") { |
| 39 | + if (result === void 0) continue; |
| 40 | + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); |
| 41 | + if (_ = accept(result.get)) descriptor.get = _; |
| 42 | + if (_ = accept(result.set)) descriptor.set = _; |
| 43 | + if (_ = accept(result.init)) initializers.unshift(_); |
| 44 | + } |
| 45 | + else if (_ = accept(result)) { |
| 46 | + if (kind === "field") initializers.unshift(_); |
| 47 | + else descriptor[key] = _; |
| 48 | + } |
| 49 | + } |
| 50 | + if (target) Object.defineProperty(target, contextIn.name, descriptor); |
| 51 | + done = true; |
| 52 | +}; |
| 53 | +var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { |
| 54 | + var useValue = arguments.length > 2; |
| 55 | + for (var i = 0; i < initializers.length; i++) { |
| 56 | + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); |
| 57 | + } |
| 58 | + return useValue ? value : void 0; |
| 59 | +}; |
| 60 | +var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) { |
| 61 | + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; |
| 62 | + var d = Object.getOwnPropertyDescriptor(f, "name"); |
| 63 | + if (d && d.writable !== false) return f; |
| 64 | + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); |
| 65 | +}; |
| 66 | +let A = (() => { |
| 67 | + let _classDecorators = [dec]; |
| 68 | + let _classDescriptor; |
| 69 | + let _classExtraInitializers = []; |
| 70 | + let _classThis; |
| 71 | + var A = class { |
| 72 | + static { _classThis = this; } |
| 73 | + static { |
| 74 | + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; |
| 75 | + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); |
| 76 | + A = _classThis = _classDescriptor.value; |
| 77 | + if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); |
| 78 | + __runInitializers(_classThis, _classExtraInitializers); |
| 79 | + } |
| 80 | + static get name() { return 123; } |
| 81 | + }; |
| 82 | + return A = _classThis; |
| 83 | +})(); |
| 84 | +let B = (() => { |
| 85 | + let _classDecorators = [dec]; |
| 86 | + let _classDescriptor; |
| 87 | + let _classExtraInitializers = []; |
| 88 | + let _classThis; |
| 89 | + var B = class { |
| 90 | + static { _classThis = this; } |
| 91 | + static { |
| 92 | + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; |
| 93 | + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); |
| 94 | + B = _classThis = _classDescriptor.value; |
| 95 | + if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); |
| 96 | + __runInitializers(_classThis, _classExtraInitializers); |
| 97 | + } |
| 98 | + static name() { return 456; } |
| 99 | + }; |
| 100 | + return B = _classThis; |
| 101 | +})(); |
| 102 | +var C = (() => { |
| 103 | + let _classDecorators = [dec]; |
| 104 | + let _classDescriptor; |
| 105 | + let _classExtraInitializers = []; |
| 106 | + let _classThis; |
| 107 | + var class_1 = class { |
| 108 | + static { _classThis = this; } |
| 109 | + static { __setFunctionName(_classThis, "C"); } |
| 110 | + static { |
| 111 | + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; |
| 112 | + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); |
| 113 | + class_1 = _classThis = _classDescriptor.value; |
| 114 | + if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); |
| 115 | + __runInitializers(_classThis, _classExtraInitializers); |
| 116 | + } |
| 117 | + static get name() { return 789; } |
| 118 | + }; |
| 119 | + return class_1 = _classThis; |
| 120 | +})(); |
| 121 | +let D = (() => { |
| 122 | + let _classDecorators = [dec]; |
| 123 | + let _classDescriptor; |
| 124 | + let _classExtraInitializers = []; |
| 125 | + let _classThis; |
| 126 | + var D = class { |
| 127 | + static { _classThis = this; } |
| 128 | + static { |
| 129 | + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; |
| 130 | + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); |
| 131 | + D = _classThis = _classDescriptor.value; |
| 132 | + if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); |
| 133 | + __runInitializers(_classThis, _classExtraInitializers); |
| 134 | + } |
| 135 | + }; |
| 136 | + return D = _classThis; |
| 137 | +})(); |
| 138 | +let E = (() => { |
| 139 | + let _classDecorators = [dec]; |
| 140 | + let _classDescriptor; |
| 141 | + let _classExtraInitializers = []; |
| 142 | + let _classThis; |
| 143 | + var E = class { |
| 144 | + static { _classThis = this; } |
| 145 | + static { |
| 146 | + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; |
| 147 | + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); |
| 148 | + E = _classThis = _classDescriptor.value; |
| 149 | + if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); |
| 150 | + } |
| 151 | + static name = "custom"; |
| 152 | + static { |
| 153 | + __runInitializers(_classThis, _classExtraInitializers); |
| 154 | + } |
| 155 | + }; |
| 156 | + return E = _classThis; |
| 157 | +})(); |
0 commit comments