Note that there are some explanatory texts on larger screens.

plurals
  1. POTypeScript Jquery Promise parameter mismatch
    primarykey
    data
    text
    <p>I'm using TypeScript 0.8.2 and the latest JQuery 1.9 .d.ts definitions from <a href="https://github.com/borisyankov/DefinitelyTyped/tree/master/jquery" rel="nofollow noreferrer">https://github.com/borisyankov/DefinitelyTyped/tree/master/jquery</a></p> <p>To isolate the problem, I have a simple TypeScript class definition that tries to make a single $.ajax call using the .when() and .then() syntax. Here's my code:</p> <pre><code>/// &lt;reference path="../../jquery.d.ts" /&gt; module Demo { // Class export class TestDeferred { // Constructor constructor() { $.when(this.testAjaxCall()).then((data, status, jqXHR: JQueryXHR) =&gt; { alert(jqXHR.statusText); }); $.when($.ajax("test.htm")).then(() =&gt; { console.log("yay"); }); } testAjaxCall() { return $.ajax("Test.aspx"); } } } </code></pre> <p>In both of these test cases, I get a compile time error that says:</p> <p>Supplied parameters do not match any signature of call target and the red squiggly is on the first parameter of the .when() method. He's a screenshot:</p> <p><img src="https://i.stack.imgur.com/bA3nI.png" alt="TypeScript JQuery Deferred Compile Problem"></p> <p>As far as I can tell, the .when() method in the .d.ts file has an overload of .when(options: any) and the .ajax is defined to be of type JQueryXHR which implements the JQueryPromise interface.</p> <p>In theory this should work just fine as it mirrors the jQuery documentation for .when() <a href="http://api.jquery.com/jQuery.when/" rel="nofollow noreferrer">http://api.jquery.com/jQuery.when/</a></p> <pre><code>$.when( $.ajax("test.aspx") ).then(function(data, textStatus, jqXHR){ alert( jqXHR.status ); // alerts 200 }); </code></pre> <p>So what am I missing? Did I define something wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload