From fbfbc7ca5eb4f0754cd6802f11cd059e6caf8a3a Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Tue, 13 Aug 2013 22:23:59 +0100 Subject: [PATCH 1/3] Fix type signatures for methods that return an IPromise --- restangular/restangular.d.ts | 54 ++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index 357750e2d..e44c1a486 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -15,45 +15,45 @@ interface Restangular extends RestangularCustom { } interface RestangularElement extends Restangular { - get (): ng.IPromise; - get (params: any): ng.IPromise; - get (params: any, headers: any): ng.IPromise; + get (): ng.IPromise; + get (params: any): ng.IPromise; + get (params: any, headers: any): ng.IPromise; - getList(): ng.IPromise; - getList(subElement: any): ng.IPromise; - getList(subElement: any, queryParams: string, headers: any): ng.IPromise; + getList(): ng.IPromise; + getList(subElement: any): ng.IPromise; + getList(subElement: any, queryParams: string, headers: any): ng.IPromise; - put(queryParams?: string, headers?: any): ng.IPromise; + put(queryParams?: string, headers?: any): ng.IPromise; - post(subElement, elementToPost, queryParams?, headers?): ng.IPromise; + post(subElement, elementToPost, queryParams?, headers?): ng.IPromise; - remove(queryParams?, headers?): ng.IPromise; - head(queryParams?, headers?): ng.IPromise; - trace(queryParams?, headers?): ng.IPromise; - options(queryParams?, headers?): ng.IPromise; - patch(queryParams?, headers?): ng.IPromise; + remove(queryParams?, headers?): ng.IPromise; + head(queryParams?, headers?): ng.IPromise; + trace(queryParams?, headers?): ng.IPromise; + options(queryParams?, headers?): ng.IPromise; + patch(queryParams?, headers?): ng.IPromise; getRestangularUrl(): string; } interface RestangularCollection extends Restangular { - getList(queryParams?, headers?): ng.IPromise; - post(elementToPost, queryParams?, headers?): ng.IPromise; - head(queryParams?, headers?): ng.IPromise; - trace(queryParams?, headers?): ng.IPromise; - options(queryParams?, headers?): ng.IPromise; - patch(queryParams?, headers?): ng.IPromise; - putElement(idx, params, headers): ng.IPromise; + getList(queryParams?, headers?): ng.IPromise; + post(elementToPost, queryParams?, headers?): ng.IPromise; + head(queryParams?, headers?): ng.IPromise; + trace(queryParams?, headers?): ng.IPromise; + options(queryParams?, headers?): ng.IPromise; + patch(queryParams?, headers?): ng.IPromise; + putElement(idx, params, headers): ng.IPromise; getRestangularUrl(): string; } interface RestangularCustom { - customGET(path, params?, headers?): ng.IPromise; - customGETLIST(path, params?, headers?): ng.IPromise; - customDELETE(path, params?, headers?): ng.IPromise; - customPOST(path, params?, headers?, elem?): ng.IPromise; - customPUT(path, params?, headers?, elem?): ng.IPromise; - customOperation(operation, path, params?, headers?, elem?): ng.IPromise; - addRestangularMethod(name, operation, path?, params?, headers?, elem?): ng.IPromise; + customGET(path, params?, headers?): ng.IPromise; + customGETLIST(path, params?, headers?): ng.IPromise; + customDELETE(path, params?, headers?): ng.IPromise; + customPOST(path, params?, headers?, elem?): ng.IPromise; + customPUT(path, params?, headers?, elem?): ng.IPromise; + customOperation(operation, path, params?, headers?, elem?): ng.IPromise; + addRestangularMethod(name, operation, path?, params?, headers?, elem?): ng.IPromise; } interface RestangularProvider { From c4ce9e97233657a1b002243b388f3fb049af6322 Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Sun, 18 Aug 2013 21:05:49 +0100 Subject: [PATCH 2/3] Remove unnecessary definitions and other small fixes - Use optional parameters to delete unnecessary definitions. - `queryParams` type is `any`, not `string`. - Delete `getList` type definition without any arguments for `RestangularElement` since the documentation says that `subElement` is mandatory (https://github.com/mgonto/restangular#element-methods) --- restangular/restangular.d.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index e44c1a486..e1c485601 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -15,18 +15,10 @@ interface Restangular extends RestangularCustom { } interface RestangularElement extends Restangular { - get (): ng.IPromise; - get (params: any): ng.IPromise; - get (params: any, headers: any): ng.IPromise; - - getList(): ng.IPromise; - getList(subElement: any): ng.IPromise; - getList(subElement: any, queryParams: string, headers: any): ng.IPromise; - - put(queryParams?: string, headers?: any): ng.IPromise; - + get (queryParams?: any, headers?: any): ng.IPromise; + getList(subElement: any, queryParams?: any, headers?: any): ng.IPromise; + put(queryParams?: any, headers?: any): ng.IPromise; post(subElement, elementToPost, queryParams?, headers?): ng.IPromise; - remove(queryParams?, headers?): ng.IPromise; head(queryParams?, headers?): ng.IPromise; trace(queryParams?, headers?): ng.IPromise; From 51181ea711c81892f8ce083e5b2f166a34621d43 Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Wed, 21 Aug 2013 10:51:25 +0100 Subject: [PATCH 3/3] "users" is a RestangularCollection, `one` -> `all --- restangular/restangular-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/restangular/restangular-tests.ts b/restangular/restangular-tests.ts index 0a2ff42a7..400b67b38 100644 --- a/restangular/restangular-tests.ts +++ b/restangular/restangular-tests.ts @@ -5,7 +5,7 @@ function test_basic() { Restangular.all('accounts'); Restangular.one('accounts', 1234); - Restangular.one('users').getList().then(function (users) { + Restangular.all('users').getList().then(function (users) { $scope.user = users[0]; }) $scope.cars = $scope.user.getList('cars'); @@ -104,4 +104,4 @@ function test_config() { elem.accountName = 'Changed'; return elem; }); -} \ No newline at end of file +}