Reputation: 1929
I'm having a bit of trouble figuring out how to write a type definition for the following code. I guess the best way to describe it is a static class that contains a named constructor.
var ajaxAdapter = new IAjaxAdapter.implement({
ajax: function (work: IAjaxRequest) {
...
}
}
But I'm getting an build error Property 'implement' does not exist on type 'typeof IAjaxAdapter'
.
My d.ts looks like this right now but obviously it's a bit wrong
export class IAjaxAdapterInstance {
constructor(any: any);
ajax: (request: IAjaxRequest) => void;
}
export class IAjaxAdapter {
implement: IAjaxAdapterInstance;
}
I'm not sure if this is possible, if not I guess I could any type it... but I was hoping for something.
Upvotes: 0
Views: 284
Reputation: 15106
Just looking at the types, since you're using implement
as a static property that refers to a class rather than an object, it should type if you add a static
and a typeof
:
export class IAjaxAdapter {
static implement: typeof IAjaxAdapterInstance;
}
Upvotes: 1