From 9b6ca433a2058cd3493ce2afeca2d87baeb71f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Campredon?= Date: Sat, 18 Jan 2014 12:01:35 +0100 Subject: [PATCH] remove void onReject oveloads --- es6-promises/es6-promises-tests.ts | 9 +------- es6-promises/es6-promises.d.ts | 33 +++++------------------------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/es6-promises/es6-promises-tests.ts b/es6-promises/es6-promises-tests.ts index 3d4af2878f..774d3763e4 100644 --- a/es6-promises/es6-promises-tests.ts +++ b/es6-promises/es6-promises-tests.ts @@ -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(); promiseNumber = thenWithNoResultAndNoReject; - //catch test var catchWithSimpleResult = promiseString.catch(error => 10); promiseNumber = catchWithSimpleResult; diff --git a/es6-promises/es6-promises.d.ts b/es6-promises/es6-promises.d.ts index cec64a9176..a44355233c 100644 --- a/es6-promises/es6-promises.d.ts +++ b/es6-promises/es6-promises.d.ts @@ -6,11 +6,9 @@ interface Thenable { then(onFulfill: (value: R) => Thenable, onReject: (error: any) => Thenable): Thenable; - then(onFulfill: (value: R) => Thenable, onReject: (error: any) => U): Thenable; + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => U): Thenable; then(onFulfill: (value: R) => U, onReject: (error: any) => Thenable): Thenable; - then(onFulfill: (value: R) => U, onReject: (error: any) => U): Thenable; - then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => void): Thenable; - then(onFulfill?: (value: R) => U, onReject?: (error: any) => void): Thenable; + then(onFulfill?: (value: R) => U, onReject?: (error: any) => U): Thenable; } @@ -54,7 +52,7 @@ declare class Promise implements Thenable { * @param onFulFill called when/if "promise" resolves * @param onReject called when/if "promise" rejects */ - then(onFulfill: (value: R) => Thenable, onReject: (error: any) => U): Promise; + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => U): Promise; /** * 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 implements Thenable { * @param onFulFill called when/if "promise" resolves * @param onReject called when/if "promise" rejects */ - then(onFulfill: (value: R) => U, onReject: (error: any) => U): Promise; - /** - * 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(onFulfill: (value: R) => Thenable, onReject?: (error: any) => void): Promise; - /** - * 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(onFulfill?: (value: R) => U, onReject?: (error: any) => void): Promise; + then(onFulfill?: (value: R) => U, onReject?: (error: any) => U): Promise; + /** * Sugar for promise.then(undefined, onRejected)