title: TypeScript class function not available
body: <p>I'm trying to call a instance method of a TypeScript class (in an ASP.NET MVC project). However, at Runtime I get exceptions like <code>0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'checkString'</code>.  </p>
  
  <p>I copied the generated JavaScript in a <a href="http://jsfiddle.net/H7FL9/2/" rel="noreferrer">jsfiddle</a> where the method seems to work.<br>
  I'm not really a JavaScript guy, so any help is much appreciated!</p>
  
  <p><strong>Things I have tried so far:</strong></p>
  
  <ol>
  <li>different browsers (Chrome: <code>Uncaught TypeError: undefined is not a function</code>, FF: <code>TypeError: this.checkString is not a function</code>)</li>
  <li>clearing browser caches</li>
  <li>deleting the temporary files of IIS Express</li>
  <li>cleaning and rebuilding the solution</li>
  <li>not using the private modifier</li>
  <li>starting the project on another machine</li>
  <li>replacing the underscore.js call with a dummy to verfiy that's not the problem</li>
  <li>checked that the instance members are correctly set</li>
  </ol>
  
  <p><strong>This is the TypeScript code:</strong></p>
  
  <pre><code>class FormData {
      BlogName: string;
      CacheTimeOut: number;
      CopyrightHolder: string;
      NavBarTitle: string;
      MarkdownExtra: boolean;
      MarkdownSanitize: boolean;
      RatingActive: boolean;
      HtmlEditor: boolean;
  
      constructor(blogName: string, cacheTimeOut: number, copyrightHolder: string, navBarTitle: string, markdownExtra: boolean, markdownSanitize: boolean, ratingActive: boolean, htmlEditor: boolean) {
          this.BlogName = blogName;
          this.CacheTimeOut = cacheTimeOut;
          this.CopyrightHolder = copyrightHolder;
          this.NavBarTitle = navBarTitle;
          this.MarkdownExtra = markdownExtra;
          this.MarkdownSanitize = markdownSanitize;
          this.RatingActive = ratingActive;
          this.HtmlEditor = htmlEditor;
      }
  
      private checkString(value: string): boolean {
          return _.isString(value) &amp;&amp; value !== '';
      }
  
      validate(): boolean {
          return (this.checkString(this.BlogName) &amp;&amp; this.checkString(this.CopyrightHolder) &amp;&amp; this.checkString(this.NavBarTitle) &amp;&amp; _.isNumber(this.CacheTimeOut) &amp;&amp; !_.isNull(this.MarkdownExtra) &amp;&amp; !_.isNull(this.MarkdownSanitize) &amp;&amp; !_.isNull(this.RatingActive));
      }       
  }
  
  //I'm calling the validate function like that (from within the same module)
  var form = getFormData(); //returns a FormData instance
  if (!form.validate()) {
      //foo
  }
  </code></pre>
  
  <p><strong>And here the generated JavaScript:</strong></p>
  
  <pre><code>var FormData = (function () {
      function FormData(blogName, cacheTimeOut, copyrightHolder, navBarTitle, markdownExtra, markdownSanitize, ratingActive, htmlEditor) {
          this.BlogName = blogName;
          this.CacheTimeOut = cacheTimeOut;
          this.CopyrightHolder = copyrightHolder;
          this.NavBarTitle = navBarTitle;
          this.MarkdownExtra = markdownExtra;
          this.MarkdownSanitize = markdownSanitize;
          this.RatingActive = ratingActive;
          this.HtmlEditor = htmlEditor;
      }
      FormData.prototype.checkString = function (value) {
          return _.isString(value) &amp;&amp; value !== '';
      };
  
      FormData.prototype.validate = function () {
          return (this.checkString(this.BlogName) &amp;&amp; this.checkString(this.CopyrightHolder) &amp;&amp; this.checkString(this.NavBarTitle) &amp;&amp; _.isNumber(this.CacheTimeOut) &amp;&amp; !_.isNull(this.MarkdownExtra) &amp;&amp; !_.isNull(this.MarkdownSanitize) &amp;&amp; !_.isNull(this.RatingActive));
      };
      return FormData;
  })();
  </code></pre>