How to create jQueryPromise void in typescript?

I'm having trouble understanding the type of jQueryPromise. I would like my promise to be of the void type, but as long as the interface definition accepts the void, I don’t know how to return / pass the promise in accordance with the interface signature. When I compile, I get an error message:

Calling type signatures '() => JQueryPromise <{}>' and '() => JQueryPromise' are not compatible.

Here is a sample code:

module Sample { export interface Ifoo { bar: () => JQueryPromise<void>; } export class fooClass implements Ifoo { bar() { var result = $.Deferred(); // logic return result.promise(); } } } 

What am I doing wrong; or what can i do right?

Thanks!

-John

+7
jquery interface jquery-deferred typescript
source share
1 answer

Use <void> when creating defferred:

 module Sample { export interface Ifoo { bar: () => JQueryPromise<void>; } export class fooClass implements Ifoo { bar() { var result = $.Deferred<void>(); // logic return result.promise(); } } } 
+15
source share

All Articles