Added typings for when that afford promise type objects being passed in and mixes of different types.

This commit is contained in:
Andrew Gaspar
2013-07-07 18:35:12 -07:00
parent e1cfc4aa71
commit f00c0421cf
2 changed files with 4 additions and 2 deletions

View File

@@ -2296,7 +2296,8 @@ function test_EventIsCallable() {
var ev = jQuery.Event('click');
}
$.when(3, "asdf").then(x => x.asdf, x => x.length); // is type JQueryPromise<any>
$.when($.ajax("/my/page.json")).then((a,b,c) => a.asdf); // is type JQueryPromise<any>
$.when("asdf", "jkl;").done(x => x.length, x=> x.length);
var f1 = $.when("fetch"); // Is type JQueryPromise<string>
var f2: JQueryPromise<string[]> = f1.then(s => [s, s]);

3
jquery/jquery.d.ts vendored
View File

@@ -265,8 +265,9 @@ interface JQueryStatic {
noConflict(removeAll?: boolean): Object;
when<T>(...deferreds: JQueryGenericPromise<T>[]): JQueryPromise<T>;
when<T>(...deferreds: T[]): JQueryPromise<T>;
when(...deferreds: any[]): JQueryPromise<any>;
when<T>(...deferreds: any[]): JQueryPromise<T>;
// CSS
css(e: any, propertyName: string, value?: any);