diff --git a/es6-promise/es6-promise-tests.ts b/es6-promise/es6-promise-tests.ts index 0980ac26c..ac4f92d3d 100644 --- a/es6-promise/es6-promise-tests.ts +++ b/es6-promise/es6-promise-tests.ts @@ -68,6 +68,9 @@ promiseNumber = thenWithUndefinedFullFillAndPromiseReject; var thenWithNoResultAndNoReject = promiseString.then(); promiseNumber = thenWithNoResultAndNoReject; +var catchAfterThen = promiseString.then().catch(); +promiseNumber = catchAfterThen; + var voidPromise = new Promise(function (resolve) { resolve(); }); //catch test @@ -161,31 +164,31 @@ getJSON('story.json').then(function(story: Story) { (document.querySelector('.spinner')).style.display = 'none'; }); -interface T1 { - __t1: string; -} - -interface T2 { - __t2: string; -} - -interface T3 { - __t3: string; -} - -function f1(): Promise { - return Promise.resolve({ __t1: "foo_t1" }); -} - -function f2(x: T1): T2 { - return { __t2: x.__t1 + ":foo_21" }; -} - -var x3 = f1() - .then(f2, (e: Error) => { - console.log("error 1"); - throw e; -}) - .then((x: T2) => { - return { __t3: x.__t2 + "bar" }; +interface T1 { + __t1: string; +} + +interface T2 { + __t2: string; +} + +interface T3 { + __t3: string; +} + +function f1(): Promise { + return Promise.resolve({ __t1: "foo_t1" }); +} + +function f2(x: T1): T2 { + return { __t2: x.__t1 + ":foo_21" }; +} + +var x3 = f1() + .then(f2, (e: Error) => { + console.log("error 1"); + throw e; +}) + .then((x: T2) => { + return { __t3: x.__t2 + "bar" }; }); \ No newline at end of file diff --git a/es6-promise/es6-promise.d.ts b/es6-promise/es6-promise.d.ts index daf7134f7..a8f8d7845 100644 --- a/es6-promise/es6-promise.d.ts +++ b/es6-promise/es6-promise.d.ts @@ -6,6 +6,7 @@ interface Thenable { then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Thenable; + catch(onRejected?: (error: any) => U | Thenable): Thenable; } declare class Promise implements Thenable {