Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$.ajax call not recognized by TypeScript

I have the following code:

    $.ajax({
        url: modal.href,
        dataType: 'json',
        type: 'POST',
        data: modal.$form.serializeArray()
    })
        .done(onSubmitDone)
        .fail(onSubmitFail);

TypeScript points to the $.ajax and gives a message saying:

Supplied parameters do not match any signature of call target.

However from what I can see my $.ajax is correct and I am correctly referencing the jQuery definitions. Can anyone suggest what might be wrong?


1 Answers

Referring to jquery.d.ts:

ajax(url: string, settings: JQueryAjaxSettings);

This is the signature of ajax function. You should move the url out of the settings object and pass in as a parameter instead for typescript to accept. Or edit the jquery.d.ts definitions to accept settings only function call.

like image 152
user1600124 Avatar answered Nov 23 '25 15:11

user1600124