title: Invoking a function from a decorator while keeping the "this" context from the original class of the function
body: <p>I want to execute a decorated function whenever something inside the decorator itself happens. My attempt already does that, but loses the execution context meanwhile. The <code>this</code> keyword becomes <code>undefined</code> in the original function.</p>
  <p>My decorator looks like this:</p>
  <pre><code>export const MyDecorator = &lt;T&gt;() =&gt; {
  
      return ( target: T, propertyKey: string, descriptor: PropertyDescriptor ) =&gt; {
  
          const originalMethod: ( ...args: any ) =&gt; unknown = descriptor.value;
  
          /* Something happened, execute function */
          setTimeout(() =&gt; {
              originalMethod.call(this);
          }, 1000);
      }
  }
  </code></pre>
  <p>I've applied the decorator to a function inside a class:</p>
  <pre><code>class MyClass {
  
      @MyDecorator()
      public myMethod() {
          console.log('I got executed!');
          console.log(this); /* undefinied */
      }
  }
  </code></pre>
  <p>I've seen this <a href="https://stackoverflow.com/questions/56189503/how-to-use-a-typescript-method-decorator-and-retain-normal-this-scope">similar question</a> before, but it doesn't talk about actually invoking the function from the decorator, but rather changing the behavior of the original function. Changing the arrow functions to anonymous functions didn't work for me. Perhaps I have missed something crucial?</p>