mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
remove void onReject oveloads
This commit is contained in:
@@ -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;
|
||||
|
||||
33
es6-promises/es6-promises.d.ts
vendored
33
es6-promises/es6-promises.d.ts
vendored
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user