remove void onReject oveloads

This commit is contained in:
François de Campredon
2014-01-18 12:01:35 +01:00
parent 5b0c3efcc2
commit 9b6ca433a2
2 changed files with 6 additions and 36 deletions

View File

@@ -44,15 +44,12 @@ promiseStringArr = allResult;
//race test
var raceResult = Promise.race(arrayOfPromise);
promiseString = raceResult;
//then test
var thenWithPromiseResult = promiseString.then(word => Promise.resolve(word.length));
promiseNumber = thenWithPromiseResult;
var thenWithPromiseResultAndVoidReject = promiseString.then(word => Promise.resolve(word.length), error => console.log(error));
promiseNumber = thenWithPromiseResultAndVoidReject;
var thenWithPromiseResultAndPromiseReject = promiseString.then(word => Promise.resolve(word.length), error => Promise.resolve(10));
promiseNumber = thenWithPromiseResultAndPromiseReject;
@@ -62,9 +59,6 @@ promiseNumber = thenWithPromiseResultAndSimpleReject;
var thenWithSimpleResult = promiseString.then(word => word.length);
promiseNumber = thenWithSimpleResult;
var thenWithSimpleResultAndVoidReject = promiseString.then(word => word.length, error => console.log(error));
promiseNumber = thenWithSimpleResultAndVoidReject;
var thenWithSimpleResultAndPromiseReject = promiseString.then(word => word.length, error => Promise.resolve(10));
promiseNumber = thenWithSimpleResultAndPromiseReject;
@@ -80,7 +74,6 @@ promiseNumber = thenWithUndefinedFullFillAndPromiseReject;
var thenWithNoResultAndNoReject = promiseString.then<number>();
promiseNumber = thenWithNoResultAndNoReject;
//catch test
var catchWithSimpleResult = promiseString.catch(error => 10);
promiseNumber = catchWithSimpleResult;

View File

@@ -6,11 +6,9 @@
interface Thenable<R> {
then<U>(onFulfill: (value: R) => Thenable<U>, onReject: (error: any) => Thenable<U>): Thenable<U>;
then<U>(onFulfill: (value: R) => Thenable<U>, onReject: (error: any) => U): Thenable<U>;
then<U>(onFulfill: (value: R) => Thenable<U>, onReject?: (error: any) => U): Thenable<U>;
then<U>(onFulfill: (value: R) => U, onReject: (error: any) => Thenable<U>): Thenable<U>;
then<U>(onFulfill: (value: R) => U, onReject: (error: any) => U): Thenable<U>;
then<U>(onFulfill: (value: R) => Thenable<U>, onReject?: (error: any) => void): Thenable<U>;
then<U>(onFulfill?: (value: R) => U, onReject?: (error: any) => void): Thenable<U>;
then<U>(onFulfill?: (value: R) => U, onReject?: (error: any) => U): Thenable<U>;
}
@@ -54,7 +52,7 @@ declare class Promise<R> implements Thenable<R> {
* @param onFulFill called when/if "promise" resolves
* @param onReject called when/if "promise" rejects
*/
then<U>(onFulfill: (value: R) => Thenable<U>, onReject: (error: any) => U): Promise<U>;
then<U>(onFulfill: (value: R) => Thenable<U>, onReject?: (error: any) => U): Promise<U>;
/**
* onFulFill is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
@@ -76,29 +74,8 @@ declare class Promise<R> implements Thenable<R> {
* @param onFulFill called when/if "promise" resolves
* @param onReject called when/if "promise" rejects
*/
then<U>(onFulfill: (value: R) => U, onReject: (error: any) => U): Promise<U>;
/**
* onFulFill is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulFill called when/if "promise" resolves
* @param onReject called when/if "promise" rejects
*/
then<U>(onFulfill: (value: R) => Thenable<U>, onReject?: (error: any) => void): Promise<U>;
/**
* onFulFill is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulFill called when/if "promise" resolves
* @param onReject called when/if "promise" rejects
*/
then<U>(onFulfill?: (value: R) => U, onReject?: (error: any) => void): Promise<U>;
then<U>(onFulfill?: (value: R) => U, onReject?: (error: any) => U): Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)