I am trying to create a typescript definition file for an existing javaScript library, but keep getting run time errors.
The library contains the following code:
/**
* Pdok namespace, will hold Api namespace
* @namespace
*/
Pdok = {};
Pdok.Api = function(config) {
/* implementation details are here... */
}
The javascript example code that was supplied works and contains the following line:
var api = new Pdok.Api(config);
I created a typescript definition file, and am able to compile without any problems. The definition looks like:
declare namespace Pdok
{
interface configOptions {
/* .. details .. */
}
class Api {
constructor(config: configOptions);
}
}
At run time, i get the following error: Uncaught TypeError: Pdok.Api is not a constructor
What should be in my .d.ts-file to get this working?
api = Pdok.Api(config)(no use ofnew) yet theApifunction does look like a constructor (usesthisa bunch and does not explicitly return anything).