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.
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:
main.js
define(function(){
var a=function(){...}; //constructor
a.prototype={...};//body
return a;
});
To use a/main in typescript, I have created a.d.ts, in which a is defined like this:
declare module "a/main"{
//I don't know how to writ this part...
}
Then I have a typescript file in which I want to use a:
otherfile.ts
///<reference path="a.d.ts"/>
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();
The problem is that modules are not new-able. so, var x=new a(); won't work.
Could you suggest the best way to declare "a/main" module?
Note: 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.