From 16bffafcfc8a9235087e9fafbb62c541e27c0161 Mon Sep 17 00:00:00 2001 From: Cyril Gandon Date: Mon, 30 Apr 2018 18:16:06 +0200 Subject: [PATCH] [restangular] extendModel and extendCollection belongs to IProvider (#25257) * [restangular] extendModel and extendCollection belongs to IProvider * fix(restangular): function returns the object --- types/restangular/index.d.ts | 4 ++-- types/restangular/restangular-tests.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/types/restangular/index.d.ts b/types/restangular/index.d.ts index e511120f57..e0a77694b2 100644 --- a/types/restangular/index.d.ts +++ b/types/restangular/index.d.ts @@ -69,6 +69,8 @@ declare namespace restangular { setSelfLinkAbsoluteUrl(value: boolean): IProvider; setParentless(value: any): IProvider; setPlainByDefault(isPlain: boolean): IProvider; + extendModel(route: string, extender: (model: IElement) => any): IProvider; + extendCollection(route: string, extender: (collection: ICollection) => any): IProvider; } interface ICustom { @@ -94,8 +96,6 @@ declare namespace restangular { restangularizeCollection(parent: any, element: any, route: string): ICollection; service(route: string, parent?: any): IScopedService; stripRestangular(element: any): any; - extendModel(route: string, extender: (model: IElement) => any): void; - extendCollection(route: string, extender: (collection: ICollection) => any): void; } interface IScopedService extends IService { diff --git a/types/restangular/restangular-tests.ts b/types/restangular/restangular-tests.ts index 2ede97a893..97739fb496 100644 --- a/types/restangular/restangular-tests.ts +++ b/types/restangular/restangular-tests.ts @@ -27,6 +27,16 @@ myApp.config((RestangularProvider: restangular.IProvider) => { return elem; }); + RestangularProvider.extendModel('accounts', function(model: any) { + model.prettifyAmount = function() {}; + return model; + }); + + RestangularProvider.extendCollection('accounts', function(collection: any) { + collection.totalAmount = function() {}; + return collection; + }); + RestangularProvider.setRestangularFields({ id: "_id", route: "restangularRoute",