title: TypeScript run-time error 'undefined'
body: <p>I have the following HTML + TypeScript that tries to instantiate a simple class called Point. When the hyperlink is clicked, I get the following errors against each try/catch clause:</p>
  
  <p><strong>Errors:</strong></p>
  
  <ul>
  <li>Cannot read property 'Empty' of undefined.</li>
  <li>undefined is not a function.</li>
  <li>undefined is not a function.</li>
  </ul>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;TypeScript HTML App&lt;/title&gt;
      &lt;script src="app.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          function Test()
          {
              try { alert(MyLibrary.Point.Empty.ToString()); }
              catch (e) { alert(e.message); }
  
              try { alert(new MyLibrary.Point(10, 20).ToString()); }
              catch (e) { alert(e.message); }
  
              try { alert(MyLibrary.Point.FromPoint(new MyLibrary.Point(10, 20)).ToString()); }
              catch (e) { alert(e.message); }
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;a href="javascript:Test();"&gt;Click Me&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>TypeScript:</strong></p>
  
  <pre><code>module MyLibrary
  {
      export interface IPoint { X: number; Y: number; ToString(): string; }
  
      export class Point implements MyLibrary.IPoint
      {
          private _X: number = 0;
          private _Y: number = 0;
  
          constructor(x: number, y: number)
          {
              this._X = x;
              this._Y = y;
          }
  
          public get X(): number { return (this._X); }
          public get Y(): number { return (this._Y); }
  
          public ToString(): string
          {
              return ("{" + this._X.toString() + "," + this._Y.toString() + "}");
          }
  
          public static FromPoint(point: MyLibrary.Point): MyLibrary.Point
          {
              return (new MyLibrary.Point(point.X, point.Y));
          }
  
          private static _Empty: MyLibrary.Point = new MyLibrary.Point(0, 0);
          public static get Empty(): MyLibrary.Point { return (MyLibrary.Point._Empty); }
      }
  }
  </code></pre>
  
  <p>The TypeScript compiles fine and the project targets ECMA5. Not sure what is going on under the hood.</p>
  
  <p><strong>UPDATE</strong>: The code starts to work if I remove the static properties from the class. Any ideas why that is? the generated JavaScript for the static properties is as follows:</p>
  
  <pre><code>Object.defineProperty(Point, "Empty", {
      get: function ()
      {
          return (MyLibrary.Point._Empty);
      },
      enumerable: true,
      configurable: true
  });
  Point._Empty = new MyLibrary.Point(0, 0);
  </code></pre>