From a6cbfba663b3ec69923b7cf85cef84ad27e640b0 Mon Sep 17 00:00:00 2001 From: reppners Date: Thu, 5 Mar 2015 08:42:15 +0100 Subject: [PATCH] + changed promise declaration to own custom since it is not possible to reuse ES6 polyfill promise class declaration --- js-data-http/js-data-http.d.ts | 10 +++++----- js-data/js-data-tests.ts | 4 +++- js-data/js-data.d.ts | 14 ++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/js-data-http/js-data-http.d.ts b/js-data-http/js-data-http.d.ts index 626f55648d..416aa3c8ca 100644 --- a/js-data-http/js-data-http.d.ts +++ b/js-data-http/js-data-http.d.ts @@ -35,11 +35,11 @@ declare module JSData { new(options?:DSHttpAdapterOptions):DSHttpAdapter; // DSHttpAdapter uses axios so options are axios config objects. - HTTP(options?:Object):Promise; - DEL(url:string, data?:Object, options?:Object):Promise; - GET(url:string, data?:Object, options?:Object):Promise; - POST(url:string, data?:Object, options?:Object):Promise; - PUT(url:string, data?:Object, options?:Object):Promise; + HTTP(options?:Object):JSDataPromise; + DEL(url:string, data?:Object, options?:Object):JSDataPromise; + GET(url:string, data?:Object, options?:Object):JSDataPromise; + POST(url:string, data?:Object, options?:Object):JSDataPromise; + PUT(url:string, data?:Object, options?:Object):JSDataPromise; } } diff --git a/js-data/js-data-tests.ts b/js-data/js-data-tests.ts index 35fdbf00f2..c6fe6d13bb 100644 --- a/js-data/js-data-tests.ts +++ b/js-data/js-data-tests.ts @@ -387,7 +387,9 @@ OtherOtherComment.find(5, {params: {postId: 4}}); // GET /post/4/comment/5 // vs -OtherOtherComment.find(5); // GET /comment/5 +var promise = OtherOtherComment.find(5); // GET /comment/5 + +promise.then().catch().finally(); OtherOtherComment.inject({id: 1, postId: 2}); diff --git a/js-data/js-data.d.ts b/js-data/js-data.d.ts index cf74b6b793..7017481ee3 100644 --- a/js-data/js-data.d.ts +++ b/js-data/js-data.d.ts @@ -3,12 +3,6 @@ // Definitions by: Stefan Steinhart // Definitions: https://github.com/borisyankov/DefinitelyTyped -/////////////////////////////////////////////////////////////////////////////// -// Promises in js-data are ES6 polyfill promises -/////////////////////////////////////////////////////////////////////////////// - -/// - /////////////////////////////////////////////////////////////////////////////// // js-data module (js-data.js) /////////////////////////////////////////////////////////////////////////////// @@ -16,10 +10,14 @@ // defining what exists in JSData and how it looks declare module JSData { - interface JSDataPromise extends Promise { + interface JSDataPromise { + + then(onFulfilled?: (value: R) => U | JSDataPromise, onRejected?: (error: any) => U | JSDataPromise): JSDataPromise; + + catch(onRejected?: (error: any) => U | JSDataPromise): JSDataPromise; // enhanced with finally - finally(finallyCb?:() => U):Promise; + finally(finallyCb?:() => U):JSDataPromise; } //TODO switch to class again when typescript supports open ended class declaration