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?
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.
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.
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With