title: Property undefined TypeScript
body: <p>I am getting a <code>TypeError</code> when executing the following code:</p>
  
  <p>server.class.ts</p>
  
  <pre><code>import {Handlers} from './handlers.class';
  export class Server{
      private _hInstance: Handlers;
      static _instance: Server;
      private constructor(){
          this._hInstance = new Handlers();
          this._hInstance.mymethod();
      }
      static instance(): Server{
          if(!!!Server._instance){
              Server._instance = new Server();
          }
          return Server._instance;
       }
  }
  </code></pre>
  
  <p>handler.class.ts</p>
  
  <pre><code>import { Polo } from './../extapi/polo.class';
  export class Handlers{
      private _polo: Polo;
      constructor(){
          this._polo = Polo.instance(); // same as Server.instance()
      }
      mymethod(){
          this._polo.someMethod(); // Error
  } 
  </code></pre>
  
  <p>The polo class uses the same technique of defining a single instance and, providing a static method <code>instance()</code> for returning the instance. That code, tested separately, works fine. The type error raises that property <code>_polo</code> of <code>undefined</code> cannot be read. This is really confusing as, the class <code>Polo</code> has been instantiated before invoking <code>someMethod</code> on its instance. </p>
  
  <p>Thanks.</p>