diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index f74f3eb44..f3a8870cd 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -1,7 +1,6 @@ // Type definitions for Angular JS 1.2 (ngResource module) // Project: http://angularjs.org -// Definitions by: Diego Vilar -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions: https://github.com/daptiv/DefinitelyTyped /// @@ -19,10 +18,19 @@ declare module ng.resource { // that deeply. /////////////////////////////////////////////////////////////////////////// interface IResourceService { + + , U extends IResourceClass>(url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): U; + >(url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): IResourceClass; (url: string, paramDefaults?: any, - /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } - where deleteDescriptor : IActionDescriptor */ - actionDescriptors?: any): IResourceClass; + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): IResourceClass>; } // Just a reference to facilitate describing new actions @@ -42,65 +50,66 @@ declare module ng.resource { // PATCH (in other words, methods with body). Otherwise, it's going // to be considered as parameters to the request. // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465 - interface IResourceClass { - get(): IResource; - get(dataOrParams: any): IResource; - get(dataOrParams: any, success: Function): IResource; - get(success: Function, error?: Function): IResource; - get(params: any, data: any, success?: Function, error?: Function): IResource; - save(): IResource; - save(dataOrParams: any): IResource; - save(dataOrParams: any, success: Function): IResource; - save(success: Function, error?: Function): IResource; - save(params: any, data: any, success?: Function, error?: Function): IResource; - query(): IResource[]; - query(dataOrParams: any): IResource[]; - query(dataOrParams: any, success: Function): IResource[]; - query(success: Function, error?: Function): IResource[]; - query(params: any, data: any, success?: Function, error?: Function): IResource[]; - remove(): IResource; - remove(dataOrParams: any): IResource; - remove(dataOrParams: any, success: Function): IResource; - remove(success: Function, error?: Function): IResource; - remove(params: any, data: any, success?: Function, error?: Function): IResource; - delete(): IResource; - delete(dataOrParams: any): IResource; - delete(dataOrParams: any, success: Function): IResource; - delete(success: Function, error?: Function): IResource; - delete(params: any, data: any, success?: Function, error?: Function): IResource; + interface IResourceClass> { + get(): T; + get(dataOrParams: any): T; + get(dataOrParams: any, success: Function): T; + get(success: Function, error?: Function): T; + get(params: any, data: any, success?: Function, error?: Function): T; + save(): T; + save(dataOrParams: any): T; + save(dataOrParams: any, success: Function): T; + save(success: Function, error?: Function): T; + save(params: any, data: any, success?: Function, error?: Function): T; + query(): T[]; + query(dataOrParams: any): T[]; + query(dataOrParams: any, success: Function): T[]; + query(success: Function, error?: Function): T[]; + query(params: any, data: any, success?: Function, error?: Function): T[]; + remove(): T; + remove(dataOrParams: any): T; + remove(dataOrParams: any, success: Function): T; + remove(success: Function, error?: Function): T; + remove(params: any, data: any, success?: Function, error?: Function): T; + delete(): T; + delete(dataOrParams: any): T; + delete(dataOrParams: any, success: Function): T; + delete(success: Function, error?: Function): T; + delete(params: any, data: any, success?: Function, error?: Function): T; } - interface IResource { - $get(): IResource; - $get(dataOrParams: any): IResource; - $get(dataOrParams: any, success: Function): IResource; - $get(success: Function, error?: Function): IResource; - $get(params: any, data: any, success?: Function, error?: Function): IResource; - $save(): IResource; - $save(dataOrParams: any): IResource; - $save(dataOrParams: any, success: Function): IResource; - $save(success: Function, error?: Function): IResource; - $save(params: any, data: any, success?: Function, error?: Function): IResource; - $query(): IResource[]; - $query(dataOrParams: any): IResource[]; - $query(dataOrParams: any, success: Function): IResource[]; - $query(success: Function, error?: Function): IResource[]; - $query(params: any, data: any, success?: Function, error?: Function): IResource[]; - $remove(): IResource; - $remove(dataOrParams: any): IResource; - $remove(dataOrParams: any, success: Function): IResource; - $remove(success: Function, error?: Function): IResource; - $remove(params: any, data: any, success?: Function, error?: Function): IResource; - $delete(): IResource; - $delete(dataOrParams: any): IResource; - $delete(dataOrParams: any, success: Function): IResource; - $delete(success: Function, error?: Function): IResource; - $delete(params: any, data: any, success?: Function, error?: Function): IResource; + interface IResource> { + $get(): T; + $get(dataOrParams: any): T; + $get(dataOrParams: any, success: Function): T; + $get(success: Function, error?: Function): T; + $get(params: any, data: any, success?: Function, error?: Function): T; + $save(): T; + $save(dataOrParams: any): T; + $save(dataOrParams: any, success: Function): T; + $save(success: Function, error?: Function): T; + $save(params: any, data: any, success?: Function, error?: Function): T; + $query(): T[]; + $query(dataOrParams: any): T[]; + $query(dataOrParams: any, success: Function): T[]; + $query(success: Function, error?: Function): T[]; + $query(params: any, data: any, success?: Function, error?: Function): T[]; + $remove(): T; + $remove(dataOrParams: any): T; + $remove(dataOrParams: any, success: Function): T; + $remove(success: Function, error?: Function): T; + $remove(params: any, data: any, success?: Function, error?: Function): T; + $delete(): T; + $delete(dataOrParams: any): T; + $delete(dataOrParams: any, success: Function): T; + $delete(success: Function, error?: Function): T; + $delete(params: any, data: any, success?: Function, error?: Function): T; } /** when creating a resource factory via IModule.factory */ - interface IResourceServiceFactoryFunction { - ($resource: ng.resource.IResourceService): ng.resource.IResourceClass; + interface IResourceServiceFactoryFunction> { + ($resource: ng.resource.IResourceService): IResourceClass; + >($resource: ng.resource.IResourceService): U; } } @@ -109,6 +118,6 @@ declare module ng { interface IModule { /** creating a resource service factory */ - factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction): IModule; + factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction): IModule; } } diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 3b0599ac4..af897a962 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -127,15 +127,15 @@ declare module ng { // this is necessary to be able to access the scoped attributes. it's not very elegant // because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way // this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656 - [name: string]: any; - - // Adds the CSS class value specified by the classVal parameter to the - // element. If animations are enabled then an animation will be triggered + [name: string]: any; + + // Adds the CSS class value specified by the classVal parameter to the + // element. If animations are enabled then an animation will be triggered // for the class addition. $addClass(classVal: string): void; - // Removes the CSS class value specified by the classVal parameter from the - // element. If animations are enabled then an animation will be triggered for + // Removes the CSS class value specified by the classVal parameter from the + // element. If animations are enabled then an animation will be triggered for // the class removal. $removeClass(classVal: string): void; @@ -143,12 +143,12 @@ declare module ng { $set(key: string, value: any): void; // Observes an interpolated attribute. - // The observer function will be invoked once during the next $digest - // following compilation. The observer is then invoked whenever the + // The observer function will be invoked once during the next $digest + // following compilation. The observer is then invoked whenever the // interpolated value changes. $observe(name: string, fn:(value?:any)=>any): Function; - // A map of DOM element attribute names to the normalized name. This is needed + // A map of DOM element attribute names to the normalized name. This is needed // to do reverse lookup from normalized name back to actual name. $attr: Object; } @@ -451,12 +451,12 @@ declare module ng { then(successCallback: (promiseValue: T) => IHttpPromise, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise; then(successCallback: (promiseValue: T) => IPromise, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise; then(successCallback: (promiseValue: T) => TResult, errorCallback?: (reason: any) => TResult, notifyCallback?: (state: any) => any): IPromise; - - + + catch(onRejected: (reason: any) => IHttpPromise): IPromise; catch(onRejected: (reason: any) => IPromise): IPromise; catch(onRejected: (reason: any) => TResult): IPromise; - + finally(finallyCallback: ()=>any):IPromise; } @@ -700,7 +700,7 @@ declare module ng { valueOf(value: any): any; } - + /////////////////////////////////////////////////////////////////////////// // SCEDelegateProvider // see http://docs.angularjs.org/api/ng.$sceDelegateProvider @@ -709,7 +709,7 @@ declare module ng { resourceUrlBlacklist(blacklist: any[]): void; resourceUrlWhitelist(whitelist: any[]): void; } - + /////////////////////////////////////////////////////////////////////////// // Directive // see http://docs.angularjs.org/api/ng.$compileProvider#directive