Merge pull request #7958 from brandf/master

bluebird: fixed inference issue with try/attempt
This commit is contained in:
Masahiro Wakame
2016-02-12 00:23:55 +09:00
3 changed files with 32 additions and 4 deletions
+15
View File
@@ -504,7 +504,16 @@ fooArrProm = fooArrProm.filter<Foo>((item: Foo) => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function getMaybePromise(): Foo|Promise<Foo> {
return foo;
}
fooProm = Promise.try(() => {
return getMaybePromise();
});
fooProm = Promise.try<Foo>(() => {
return getMaybePromise();
});
fooProm = Promise.try(() => {
return foo;
});
@@ -529,6 +538,12 @@ fooProm = Promise.try(() => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = Promise.attempt(() => {
return getMaybePromise();
});
fooProm = Promise.attempt<Foo>(() => {
return getMaybePromise();
});
fooProm = Promise.attempt(() => {
return foo;
});
+2 -4
View File
@@ -319,11 +319,9 @@ declare class Promise<R> implements Promise.Thenable<R> {
*
* Alias for `attempt();` for compatibility with earlier ECMAScript version.
*/
static try<R>(fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
static try<R>(fn: () => R, args?: any[], ctx?: any): Promise<R>;
static try<R>(fn: () => R | Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
static attempt<R>(fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
static attempt<R>(fn: () => R, args?: any[], ctx?: any): Promise<R>;
static attempt<R>(fn: () => R | Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
/**
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
+15
View File
@@ -673,7 +673,16 @@ fooArrProm = fooArrProm.each<Foo, Bar>((item: Foo, index: number, arrayLength: n
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function getMaybePromise(): Foo|Promise<Foo> {
return foo;
}
fooProm = Promise.try(() => {
return getMaybePromise();
});
fooProm = Promise.try<Foo>(() => {
return getMaybePromise();
});
fooProm = Promise.try(() => {
return foo;
});
@@ -707,6 +716,12 @@ fooProm = Promise.try(() => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = Promise.attempt(() => {
return getMaybePromise();
});
fooProm = Promise.attempt<Foo>(() => {
return getMaybePromise();
});
fooProm = Promise.attempt(() => {
return foo;
});