title: Typescript Class member function not accessible
body: <p>I am new to typescript, while working on an problem I created following class</p>
  
  <pre><code>export class ModuleInfoContainer extends Array&lt;ModuleInfo&gt;  {
    constructor() {
      super();
    }
    search(id: number) {
      let k: ModuleInfo;
      this.every(a =&gt; {
          k = a.search(id);
          return !k;
      });
      return k;
    }
  }
  </code></pre>
  
  <p>I expected it to work, but while debugging, all array functions were accessible but member function <code>search</code> of <code>ModuleInfoContainer</code> was not accessible.
  however after a few google searches i got an example, and ended up with this code</p>
  
  <pre><code>export class ModuleInfoContainer extends Array&lt;ModuleInfo&gt;  {
    constructor() {
      super();
    }
  search = function (id: number) {
      let k: ModuleInfo;
      this.every(a =&gt; {
          k = a.search(id);
          return !k;
      });
      return k;
    };
  }
  </code></pre>
  
  <p>and it was working as expected.</p>
  
  <p>what's wrong in first code?</p>
  
  <p><strong>EDIT: <code>ModuleInfo</code> class</strong></p>
  
  <pre><code>export class ModuleInfo {
    Id: number;
    Name: string;
    DisplayName: string;
    ChildModules: ModuleInfoContainer;
    DependsOn: ModuleInfo[];
    parent: ModuleInfo;
    search(id: number): ModuleInfo {
      if (this.Id === id) {
          return this;
      } else if (this.ChildModules &amp;&amp; this.ChildModules.length) {
          return this.ChildModules.search(id);
      }
      return undefined;
    }
  }
  </code></pre>
  
  <p>This Is how I was trying to call this my search function:</p>
  
  <pre><code>let k = new ModuleInfoContainer();
  k.search(1);
  </code></pre>
  
  <p>typescript compiles successfully but there is an error on runtime, saying <code>k does not have a member function named search</code>(error may not be exactly same as given by chrome but meaning was same).
  however second code works fine.</p>