Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I get the latest typescript JQuery definition file from?

Tags:

typescript

I know there are some problems with the definition file that I have already downloaded. For example here with the following $.ajax call:

$.ajax("/Admin/xx",
{
    cache: false
})

Note that I need to specify the URL first. I recall reading that this was understood as an error.

Where can I get the latest JQuery definition file from. Anyone have any news as to when Microsoft will come out with an update to the Alpha version of Typescript that they have now?

like image 435
Samantha J T Star Avatar asked Nov 12 '12 16:11

Samantha J T Star


People also ask

Do you need to install type definitions for jQuery?

Most likely you need to download and include the TypeScript declaration file for jQuery— jquery. d. ts —in your project. Then the compiler will resolve the definitions for jquery automatically.


2 Answers

You can find a fork of the jQuery definitions from the TypeScript's repo here:

DefinitelyTyped

It contains dozens of fixes over the original, including the ajax() overload. Once the TypeScript team starts accepting pull requests, I will push the fixes there.

On updates to TypeScript itself: it is not an alpha, but a preview. 0.8.1 version is being baked in the repos, and they have said they hope for a 2013 final version.

like image 123
Boris Yankov Avatar answered Sep 25 '22 09:09

Boris Yankov


Update! The Definitely Typed project is now the correct place to grab your definitions - and Microsoft are now actively involved with Definitely Typed.

The very latest official typing for jQuery can be found on the TypeScript Codeplex site. (project has moved).

I believe the definition is currently:

ajax(url: string, settings: JQueryAjaxSettings);

This is correct, but it is not the only variation of the ajax function, it should really be overloaded with a definition for:

ajax(settings: JQueryAjaxSettings);

You could add support to this in your own code by adding your own extension on top of the TypeScript jquery.d.ts definition and remove this when the jquery.d.ts file gets updated - when it is, you'll get a build warning about a duplicate definition to remind you to do this.

declare interface JQueryStatic {
    ajax(settings: JQueryAjaxSettings);
}
like image 31
Fenton Avatar answered Sep 23 '22 09:09

Fenton