title: TypeScript + AMD: how to declare anonymous class inside a module?
body: <p>Basically, I want to define an interface for an AMD js module which is accessed from a ts file. The problem is that the module import in ts does not return the anonymous class that is typically defined and returned in a AMD js module. So I can not use 'new' to instantiate them.   </p>
  
  <p>I have an AMD module (it's the main file of a package and I refer to it as 'a/main' in other modules) which is like this:</p>
  
  <p><strong>main.js</strong></p>
  
  <pre><code>define(function(){   
    var a=function(){...}; //constructor
    a.prototype={...};//body   
  
    return a;
  });
  </code></pre>
  
  <p>To use a/main in typescript, I have created <strong>a.d.ts</strong>, in which a is defined like this:</p>
  
  <pre><code>declare module "a/main"{
      //I don't know how to writ this part... 
  }
  </code></pre>
  
  <p>Then I have a typescript file in which I want to use a:</p>
  
  <p><strong>otherfile.ts</strong></p>
  
  <pre><code>///&lt;reference path="a.d.ts"/&gt;
  import a=module("a/main"); //here a should refer to a inside the main.
  //so I should be able to say:
  var x=new a();
  </code></pre>
  
  <p>The problem is that modules are not new-able. so, var x=new a(); won't work.</p>
  
  <p>Could you suggest the best way to declare "a/main" module?</p>
  
  <p><strong>Note:</strong> I have many files like a.js and prefer to find a way to write .d.ts files in a way so that I do not need to change all my .js files, i.e., changing the .js files is the last resort.    </p>