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

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.


From DefinitelyTyped, declaration file for jQuery 1.10.x / 2.0.x is here:

https://github.com/borisyankov/DefinitelyTyped/blob/master/jquery/jquery.d.ts (dead link)

..or in the raw form:

https://raw.githubusercontent.com/borisyankov/DefinitelyTyped/master/jquery/jquery.d.ts

Google Hosted Libraries distributes (as of today) jQuery 2.1.3 which is the one I prefer to use. I don't know to what extent the API has changed between 2.0 and 2.1. But if you ever discover a bug in your TypeScript application, then it might be because of a small API change in the latest version of jQuery that has not propagated to the declaration files provided above.


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);
}

Tags:

Typescript