|
| 1 | +//// [tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts] //// |
| 2 | + |
| 3 | +//// [a.ts] |
| 4 | + |
| 5 | +// from #3108 |
| 6 | +export var test = 'abc'; |
| 7 | + |
| 8 | +//// [b.ts] |
| 9 | +import { test } from './a'; |
| 10 | + |
| 11 | +function filter(handler: any) { |
| 12 | + return function (target: any) { |
| 13 | + // ... |
| 14 | + }; |
| 15 | +} |
| 16 | + |
| 17 | +class Wat { |
| 18 | + @filter(() => test == 'abc') |
| 19 | + static whatever() { |
| 20 | + // ... |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +//// [a.js] |
| 25 | +// from #3108 |
| 26 | +exports.test = 'abc'; |
| 27 | +//// [b.js] |
| 28 | +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { |
| 29 | + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); |
| 30 | + switch (arguments.length) { |
| 31 | + case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); |
| 32 | + case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); |
| 33 | + case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); |
| 34 | + } |
| 35 | +}; |
| 36 | +var a_1 = require('./a'); |
| 37 | +function filter(handler) { |
| 38 | + return function (target) { |
| 39 | + // ... |
| 40 | + }; |
| 41 | +} |
| 42 | +var Wat = (function () { |
| 43 | + function Wat() { |
| 44 | + } |
| 45 | + Wat.whatever = function () { |
| 46 | + // ... |
| 47 | + }; |
| 48 | + Object.defineProperty(Wat, "whatever", |
| 49 | + __decorate([ |
| 50 | + filter(function () { return a_1.test == 'abc'; }) |
| 51 | + ], Wat, "whatever", Object.getOwnPropertyDescriptor(Wat, "whatever"))); |
| 52 | + return Wat; |
| 53 | +})(); |
0 commit comments