title: In typescript, why isn't it possible to initialize a class property by calling a method?
body: <p>The following typescript code works as expected but typescript throws a TS2564 error on the test2 and test3 properties. Is it because they are initialized inside of methods? How should a class like this be written.</p>
  <p>I believe it works as expected because it is valid in javascript. Could it be caused by wrong typescript settings?</p>
  <pre><code>class class1{
  
      test1:number;//test1 is initialized as expected
      test2:number;//Property 'test2' has no initializer and is not definitely assigned in the constructor.
      test3:number;//Property 'test3' has no initializer and is not definitely assigned in the constructor.
  
      constructor(){
          //test1 
          this.test1 = 0;
  
          //test2
          const setTest2To0 = () =&gt;{
              this.test2 = 0;
          };
          setTest2To0();
  
          //test3
          this.setTest3To0();
      }
  
      setTest3To0(){
          this.test3 = 0;
      }}
  </code></pre>