From f00c0421cfc1f4f6da179c66a9a614ae6011060b Mon Sep 17 00:00:00 2001 From: Andrew Gaspar Date: Sun, 7 Jul 2013 18:35:12 -0700 Subject: [PATCH] Added typings for when that afford promise type objects being passed in and mixes of different types. --- jquery/jquery-tests.ts | 3 ++- jquery/jquery.d.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 9e1649ea9..4fb31f0ed 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -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 +$.when($.ajax("/my/page.json")).then((a,b,c) => a.asdf); // is type JQueryPromise +$.when("asdf", "jkl;").done(x => x.length, x=> x.length); var f1 = $.when("fetch"); // Is type JQueryPromise var f2: JQueryPromise = f1.then(s => [s, s]); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 20def6877..57dfff6be 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -265,8 +265,9 @@ interface JQueryStatic { noConflict(removeAll?: boolean): Object; + when(...deferreds: JQueryGenericPromise[]): JQueryPromise; when(...deferreds: T[]): JQueryPromise; - when(...deferreds: any[]): JQueryPromise; + when(...deferreds: any[]): JQueryPromise; // CSS css(e: any, propertyName: string, value?: any);