title: setInterval and setTimeout in Typescript
body: <p>I am learning Typescript and am trying to print a console message a number of times over a period of time. <strong>But in my test this happens once</strong>, you know the reason?</p>
  
  <p>The code is below:</p>
  
  <pre><code> class Class {
      private msg: string;
      constructor(msg: string) {
          this.msg = msg;
      }
      private printMsg(): void {
          console.log(this.msg);
      };
      public repeatMsg(): void {
          let intervalo = setInterval(this.printMsg(), 2000);
          setTimeout(function() {
              clearInterval(intervalo);
          }, 40000);
      }
  }
  
  let test: Class;
  test = new Class("Hello");
  test.repeatMsg();
  </code></pre>