From 310d3afe0d557b13f539d370047929734fd709e7 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Mon, 8 Sep 2014 17:09:41 +0200 Subject: [PATCH] Fixes #2788 Correctly declare the return type of promise.filter and promise.map --- bluebird/bluebird-tests.ts | 8 ++++---- bluebird/bluebird.d.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index abead4237..6eb154e83 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -477,10 +477,10 @@ barProm = fooProm.race(); //TODO fix collection inference -barProm = fooProm.map((item: Foo, index: number, arrayLength: number) => { +barArrProm = fooProm.map((item: Foo, index: number, arrayLength: number) => { return bar; }); -barProm = fooProm.map((item: Foo) => { +barArrProm = fooProm.map((item: Foo) => { return bar; }); @@ -495,10 +495,10 @@ barProm = fooProm.reduce((memo: Bar, item: Foo) => { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -fooProm = fooProm.filter((item: Foo, index: number, arrayLength: number) => { +fooArrProm = fooArrProm.filter((item: Foo, index: number, arrayLength: number) => { return bool; }); -fooProm = fooProm.filter((item: Foo) => { +fooArrProm = fooArrProm.filter((item: Foo) => { return bool; }); diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index 8912ebb88..210032f86 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -296,8 +296,8 @@ declare class Promise implements Promise.Thenable { * Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ // TODO type inference from array-resolving promise? - map(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable): Promise; - map(mapper: (item: Q, index: number, arrayLength: number) => U): Promise; + map(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable): Promise; + map(mapper: (item: Q, index: number, arrayLength: number) => U): Promise; /** * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. @@ -310,8 +310,8 @@ declare class Promise implements Promise.Thenable { * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ // TODO type inference from array-resolving promise? - filter(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable): Promise; - filter(filterer: (item: U, index: number, arrayLength: number) => boolean): Promise; + filter(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable): Promise; + filter(filterer: (item: U, index: number, arrayLength: number) => boolean): Promise; /** * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.