title: Typescript class method called by external function vs internal function
body: <p>I have have a class like this: </p>
  
  <pre><code>export class HelloComponent {
  
    recipient = 'World';
  
    constructor() {
      this.sayHello();
    }
  
    sayHello() {
      const msg = `Hello ${this.recipient}`;
      console.log(msg);
    }
  }
  </code></pre>
  
  <p>When called from the constructor, <code>sayHello</code> works fine.</p>
  
  <p>However when the method gets called by <code>window.requestAnimationFrame</code> it throws: </p>
  
  <pre><code>// Uncaught TypeError: Cannot read property 'recipient' of null
  </code></pre>
  
  <p>What's wrong?</p>