summaryrefslogtreecommitdiff
path: root/tests/testdata/run/runtime_decorators.ts
blob: 40a26bbd4d1948a66a3bc5c90790f98d1a20dc80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// deno-lint-ignore-file
function a() {
  console.log("@A evaluated");
  return function (
    target: any,
    propertyKey: string,
    descriptor: PropertyDescriptor,
  ) {
    console.log("@A called");
    const fn = descriptor.value;
    descriptor.value = function () {
      console.log("fn() called from @A");
      fn();
    };
  };
}

function b() {
  console.log("@B evaluated");
  return function (
    target: any,
    propertyKey: string,
    descriptor: PropertyDescriptor,
  ) {
    console.log("@B called");
    const fn = descriptor.value;
    descriptor.value = function () {
      console.log("fn() called from @B");
      fn();
    };
  };
}

class C {
  @a()
  @b()
  static test() {
    console.log("C.test() called");
  }
}

C.test();