diff --git a/angularjs/README.md b/angularjs/README.md index cdd9524547..94dc303ae4 100644 --- a/angularjs/README.md +++ b/angularjs/README.md @@ -19,6 +19,7 @@ The following extra definition files are available for referencing: * angular-route.d.ts (for the **ngRoute** module) * angular-cookies.d.ts (for the **ngCookies** module) * angular-sanitize.d.ts (for the **ngSanitize** module) +* angular-animate.d.ts (for the **ngAnimate** module) * angular-mocks.d.ts (for the **ngMock** and **ngMockE2E** modules) (postfix with version number for specific verion, eg. angular-resource-1.0.d.ts) @@ -39,6 +40,7 @@ To avoid cluttering the list of suggestions as you type in your IDE, all interfa * `ng.resource` for **ngResource** * `ng.route` for **ngRoute** * `ng.sanitize` for **ngSanitize** +* `ng.animate` for **ngAnimate** **ngMockE2E** does not define a new namespace, but rather modifies some of **ng**'s interfaces. diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index be83611e07..a34bd479f1 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.3 (ngAnimate module) +// Type definitions for Angular JS 1.5 (ngAnimate module) // Project: http://angularjs.org // Definitions by: Michel Salib , Adi Dahiya , Raphael Schweizer , Cody Schaaf // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -14,19 +14,54 @@ declare module "angular-animate" { * ngAnimate module (angular-animate.js) */ declare module angular.animate { - interface IAnimateFactory extends Function { - enter?: (element: ng.IAugmentedJQuery, doneFn: Function) => IAnimateCssRunner|void; - leave?: (element: ng.IAugmentedJQuery, doneFn: Function) => IAnimateCssRunner|void; - addClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void; - removeClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void; - setClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void; + interface IAnimateFactory { + (...args: any[]): IAnimateCallbackObject; } + interface IAnimateCallbackObject { + eventFn?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any; + setClass?: (element: IAugmentedJQuery, addedClasses: string, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any; + addClass?: (element: IAugmentedJQuery, addedClasses: string, doneFunction: Function, options: IAnimationOptions) => any; + removeClass?: (element: IAugmentedJQuery, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any; + enter?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any; + leave?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any; + move?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any; + animate?: (element: IAugmentedJQuery, fromStyles: string, toStyles: string, doneFunction: Function, options: IAnimationOptions) => any; + } + + interface IAnimationPromise extends IPromise {} + /** * AnimateService * see http://docs.angularjs.org/api/ngAnimate/service/$animate */ interface IAnimateService { + /** + * Sets up an event listener to fire whenever the animation event has fired on the given element or among any of its children. + * + * @param event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...) + * @param container the container element that will capture each of the animation events that are fired on itself as well as among its children + * @param callback the callback function that will be fired when the listener is triggered + */ + on(event: string, container: JQuery, callback: Function): void; + + /** + * Deregisters an event listener based on the event which has been associated with the provided element. + * + * @param event the animation event (e.g. enter, leave, move, addClass, removeClass, etc...) + * @param container the container element the event listener was placed on + * @param callback the callback function that was registered as the listener + */ + off(event: string, container?: JQuery, callback?: Function): void; + + /** + * Associates the provided element with a host parent element to allow the element to be animated even if it exists outside of the DOM structure of the Angular application. + * + * @param element the external element that will be pinned + * @param parentElement the host parent element that will be associated with the external element + */ + pin(element: JQuery, parentElement: JQuery): void; + /** * Globally enables / disables animations. * @@ -34,7 +69,13 @@ declare module angular.animate { * @param value If provided then set the animation on or off. * @returns current animation state */ - enabled(element?: JQuery, value?: boolean): boolean; + enabled(element: JQuery, value?: boolean): boolean; + enabled(value: boolean): boolean; + + /** + * Cancels the provided animation. + */ + cancel(animationPromise: IAnimationPromise): void; /** * Performs an inline animation on the element. @@ -46,7 +87,7 @@ declare module angular.animate { * @param options an optional collection of styles that will be picked up by the CSS transition/animation * @returns the animation callback promise */ - animate(element: JQuery, from: any, to: any, className?: string, options?: IAnimationOptions): IPromise; + animate(element: JQuery, from: any, to: any, className?: string, options?: IAnimationOptions): IAnimationPromise; /** * Appends the element to the parentElement element that resides in the document and then runs the enter animation. @@ -57,7 +98,7 @@ declare module angular.animate { * @param options an optional collection of styles that will be picked up by the CSS transition/animation * @returns the animation callback promise */ - enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, options?: IAnimationOptions): IPromise; + enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, options?: IAnimationOptions): IAnimationPromise; /** * Runs the leave animation operation and, upon completion, removes the element from the DOM. @@ -66,7 +107,7 @@ declare module angular.animate { * @param options an optional collection of styles that will be picked up by the CSS transition/animation * @returns the animation callback promise */ - leave(element: JQuery, options?: IAnimationOptions): IPromise; + leave(element: JQuery, options?: IAnimationOptions): IAnimationPromise; /** * Fires the move DOM operation. Just before the animation starts, the animate service will either append @@ -78,7 +119,7 @@ declare module angular.animate { * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation * @returns the animation callback promise */ - move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): IPromise; + move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): IAnimationPromise; /** * Triggers a custom animation event based off the className variable and then attaches the className @@ -89,7 +130,7 @@ declare module angular.animate { * @param options an optional collection of styles that will be picked up by the CSS transition/animation * @returns the animation callback promise */ - addClass(element: JQuery, className: string, options?: IAnimationOptions): IPromise; + addClass(element: JQuery, className: string, options?: IAnimationOptions): IAnimationPromise; /** * Triggers a custom animation event based off the className variable and then removes the CSS class @@ -100,7 +141,7 @@ declare module angular.animate { * @param options an optional collection of styles that will be picked up by the CSS transition/animation * @returns the animation callback promise */ - removeClass(element: JQuery, className: string, options?: IAnimationOptions): IPromise; + removeClass(element: JQuery, className: string, options?: IAnimationOptions): IAnimationPromise; /** * Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback @@ -112,12 +153,7 @@ declare module angular.animate { * @param options an optional collection of styles that will be picked up by the CSS transition/animation * @returns the animation callback promise */ - setClass(element: JQuery, add: string, remove: string, options?: IAnimationOptions): IPromise; - - /** - * Cancels the provided animation. - */ - cancel(animationPromise: IPromise): void; + setClass(element: JQuery, add: string, remove: string, options?: IAnimationOptions): IAnimationPromise; } /** @@ -131,7 +167,7 @@ declare module angular.animate { * @param name The name of the animation. * @param factory The factory function that will be executed to return the animation object. */ - register(name: string, factory: () => IAnimateCallbackObject): void; + register(name: string, factory: IAnimateFactory): void; /** * Gets and/or sets the CSS class expression that is checked when performing an animation. @@ -252,10 +288,10 @@ declare module angular.animate { (element: JQuery, animateCssOptions: IAnimationOptions): IAnimateCssRunner; } -} - -declare module angular { interface IModule { - animate(cssSelector: string, animateFactory: angular.animate.IAnimateFactory): IModule; + animation(name: string, animationFactory: IAnimateFactory): IModule; + animation(name: string, inlineAnnotatedFunction: any[]): IModule; + animation(object: Object): IModule; } + } diff --git a/angularjs/angular-resource-tests.ts b/angularjs/angular-resource-tests.ts index fcf0bd0a96..5a9963b14c 100644 --- a/angularjs/angular-resource-tests.ts +++ b/angularjs/angular-resource-tests.ts @@ -1,14 +1,19 @@ /// -interface IMyResource extends angular.resource.IResource { }; -interface IMyResourceClass extends angular.resource.IResourceClass { }; + +import IHttpPromiseCallbackArg = angular.IHttpPromiseCallbackArg; + +interface IMyData {} +interface IMyHttpPromiseCallbackArg extends IHttpPromiseCallbackArg {} +interface IMyResource extends angular.resource.IResource { } +interface IMyResourceClass extends angular.resource.IResourceClass { } /////////////////////////////////////// // IActionDescriptor /////////////////////////////////////// var actionDescriptor: angular.resource.IActionDescriptor; -angular.injector(['ng']).invoke(function ($cacheFactory: angular.ICacheFactoryService, $timeout: angular.ITimeoutService) { +angular.injector(['ng']).invoke(function ($cacheFactory: angular.ICacheFactoryService) { actionDescriptor.method = 'method action'; actionDescriptor.params = { key: 'value' }; actionDescriptor.url = '/api/test-url/'; @@ -21,10 +26,13 @@ angular.injector(['ng']).invoke(function ($cacheFactory: angular.ICacheFactorySe actionDescriptor.cache = true; actionDescriptor.cache = $cacheFactory('cacheId'); actionDescriptor.timeout = 1000; - actionDescriptor.timeout = $timeout(function () { }); actionDescriptor.withCredentials = true; actionDescriptor.responseType = 'response type'; - actionDescriptor.interceptor = { key: 'value' }; + actionDescriptor.interceptor = { + response: function () { return {}; }, + responseError: function () {} + }; + actionDescriptor.cancellable = true; }); @@ -44,6 +52,7 @@ resource = resourceClass.delete({ key: 'value' }, { key: 'value' }); resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }); resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); resource.$promise.then(function(data: IMyResource) {}); +resource.$cancelRequest(); resource = resourceClass.get(); resource = resourceClass.get({ key: 'value' }); diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 1e82f31545..0db2c2070d 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.3 (ngResource module) +// Type definitions for Angular JS 1.5 (ngResource module) // Project: http://angularjs.org // Definitions by: Diego Vilar , Michael Jess // Definitions: https://github.com/daptiv/DefinitelyTyped @@ -23,6 +23,11 @@ declare module angular.resource { * If true then the trailing slashes from any calculated URL will be stripped (defaults to true) */ stripTrailingSlashes?: boolean; + /** + * If true, the request made by a "non-instance" call will be cancelled (if not already completed) by calling + * $cancelRequest() on the call's return value. This can be overwritten per action. (Defaults to false.) + */ + cancellable?: boolean; } @@ -58,10 +63,16 @@ declare module angular.resource { transformResponse?: angular.IHttpResponseTransformer | angular.IHttpResponseTransformer[]; headers?: any; cache?: boolean | angular.ICacheObject; - timeout?: number | angular.IPromise; + /** + * Note: In contrast to $http.config, promises are not supported in $resource, because the same value + * would be used for multiple requests. If you are looking for a way to cancel requests, you should + * use the cancellable option. + */ + timeout?: number + cancellable?: boolean; withCredentials?: boolean; responseType?: string; - interceptor?: any; + interceptor?: IHttpInterceptor; } // Baseclass for everyresource with default actions. @@ -137,6 +148,8 @@ declare module angular.resource { $delete(params?: Object, success?: Function, error?: Function): angular.IPromise; $delete(success: Function, error?: Function): angular.IPromise; + $cancelRequest(): void; + /** the promise of the original server interaction that created this instance. **/ $promise : angular.IPromise; $resolved : boolean; diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 5f8270e593..a0190b9a61 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -62,6 +62,10 @@ angular.module('http-auth-interceptor', []) */ .config(['$httpProvider', 'authServiceProvider', function ($httpProvider: ng.IHttpProvider, authServiceProvider: any) { + $httpProvider.defaults.headers.common = {'Authorization': 'Bearer token'}; + $httpProvider.defaults.headers.get['Authorization'] = 'Bearer token'; + $httpProvider.defaults.headers.post['Authorization'] = function (config:ng.IRequestConfig):string { return 'Bearer token'; } + var interceptor = ['$rootScope', '$q', function ($rootScope: ng.IScope, $q: ng.IQService) { function success(response: ng.IHttpPromiseCallbackArg) { return response; @@ -510,6 +514,7 @@ test_IAttributes({ $normalize: function (classVal){ return "foo" }, $addClass: function (classVal){}, $removeClass: function(classVal){}, + $updateClass: function(newClass, oldClass){}, $set: function(key, value){}, $observe: function(name: any, fn: any){ return fn; @@ -748,6 +753,7 @@ angular.module('docsTransclusionExample', []) }; }); + angular.module('docsIsoFnBindExample', []) .controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) { $scope.name = 'Tobias'; @@ -847,6 +853,30 @@ angular.module('docsTabsExample', []) }; }); +angular.module('componentExample', []) + .component('counter', { + require: ['^ctrl'], + bindings: { + count: '=' + }, + controller: 'CounterCtrl', + controllerAs: 'counterCtrl', + template: function () { + return ''; + }, + transclude: { + 'el': 'target' + } + }) + .component('anotherCounter', { + controller: function(){}, + require: { + 'parent': '^parentCtrl' + }, + template: '', + transclude: true + }); + interface copyExampleUser { name?: string; email?: string; diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 656e62865b..4716cc6529 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.4+ +// Type definitions for Angular JS 1.5 // Project: http://angularjs.org // Definitions by: Diego Vilar // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -178,9 +178,6 @@ declare module angular { // see http://docs.angularjs.org/api/angular.Module /////////////////////////////////////////////////////////////////////////// interface IModule { - animation(name: string, animationFactory: Function): IModule; - animation(name: string, inlineAnnotatedFunction: any[]): IModule; - animation(object: Object): IModule; /** * Use this method to register a component. * @@ -336,6 +333,12 @@ declare module angular { */ $removeClass(classVal: string): void; + /** + * Adds and removes the appropriate CSS class values to the element based on the difference between + * the new and old CSS class values (specified as newClasses and oldClasses). + */ + $updateClass(newClasses: string, oldClasses: string): void; + /** * Set DOM element attribute value. */ @@ -605,15 +608,6 @@ declare module angular { [key: string]: any; } - /////////////////////////////////////////////////////////////////////////// - // BrowserService - // TODO undocumented, so we need to get it from the source code - /////////////////////////////////////////////////////////////////////////// - interface IBrowserService { - defer: angular.ITimeoutService; - [key: string]: any; - } - /////////////////////////////////////////////////////////////////////////// // TimeoutService // see http://docs.angularjs.org/api/ng.$timeout @@ -633,35 +627,6 @@ declare module angular { cancel(promise: IPromise): boolean; } - /////////////////////////////////////////////////////////////////////////// - // AnimateProvider - // see http://docs.angularjs.org/api/ng/provider/$animateProvider - /////////////////////////////////////////////////////////////////////////// - interface IAnimateProvider { - /** - * Registers a new injectable animation factory function. - * - * @param name The name of the animation. - * @param factory The factory function that will be executed to return the animation object. - */ - register(name: string, factory: () => IAnimateCallbackObject): void; - - /** - * Gets and/or sets the CSS class expression that is checked when performing an animation. - * - * @param expression The className expression which will be checked against all animations. - * @returns The current CSS className expression value. If null then there is no expression value. - */ - classNameFilter(expression?: RegExp): RegExp; - } - - /** - * The animation object which contains callback functions for each event that is expected to be animated. - */ - interface IAnimateCallbackObject { - eventFn(element: Node, doneFn: () => void): Function; - } - /** * $filter - $filterProvider - service in module ng * @@ -1209,10 +1174,15 @@ declare module angular { interface ICompileProvider extends IServiceProvider { directive(name: string, directiveFactory: Function): ICompileProvider; + directive(directivesMap: Object, directiveFactory: Function): ICompileProvider; + directive(name: string, inlineAnnotatedFunction: any[]): ICompileProvider; + directive(directivesMap: Object, inlineAnnotatedFunction: any[]): ICompileProvider; // Undocumented, but it is there... directive(directivesMap: any): ICompileProvider; + component(name: string, options: IComponentOptions): ICompileProvider; + aHrefSanitizationWhitelist(): RegExp; aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider; @@ -1258,6 +1228,15 @@ declare module angular { allowGlobals(): void; } + /** + * xhrFactory + * Replace or decorate this service to create your own custom XMLHttpRequest objects. + * see https://docs.angularjs.org/api/ng/service/$xhrFactory + */ + interface IXhrFactory { + (method: string, url: string): T; + } + /** * HttpService * see http://docs.angularjs.org/api/ng/service/$http @@ -1399,8 +1378,18 @@ declare module angular { } interface IHttpPromise extends IPromise> { - success(callback: IHttpPromiseCallback): IHttpPromise; - error(callback: IHttpPromiseCallback): IHttpPromise; + /** + * The $http legacy promise methods success and error have been deprecated. Use the standard then method instead. + * If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error. + * @deprecated + */ + success?(callback: IHttpPromiseCallback): IHttpPromise; + /** + * The $http legacy promise methods success and error have been deprecated. Use the standard then method instead. + * If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error. + * @deprecated + */ + error?(callback: IHttpPromiseCallback): IHttpPromise; } // See the jsdoc for transformData() at https://github.com/angular/angular.js/blob/master/src/ng/http.js#L228 @@ -1413,13 +1402,15 @@ declare module angular { (data: any, headersGetter: IHttpHeadersGetter, status: number): any; } + type HttpHeaderType = {[requestType: string]:string|((config:IRequestConfig) => string)}; + interface IHttpRequestConfigHeaders { - [requestType: string]: string|(() => string); - common?: string|(() => string); - get?: string|(() => string); - post?: string|(() => string); - put?: string|(() => string); - patch?: string|(() => string); + [requestType: string]: any; + common?: any; + get?: any; + post?: any; + put?: any; + patch?: any; } /** @@ -1479,7 +1470,7 @@ declare module angular { interface IHttpInterceptor { request?: (config: IRequestConfig) => IRequestConfig|IPromise; requestError?: (rejection: any) => any; - response?: (response: IHttpPromiseCallbackArg) => IPromise|T; + response?: (response: IHttpPromiseCallbackArg) => IPromise>|IHttpPromiseCallbackArg; responseError?: (rejection: any) => any; } @@ -1685,10 +1676,11 @@ declare module angular { * Controller constructor function that should be associated with newly created scope or the name of a registered * controller if passed as a string. Empty function by default. */ - controller?: any; + controller?: string | Function; /** * An identifier name for a reference to the controller. If present, the controller will be published to scope under * the controllerAs name. If not present, this will default to be the same as the component name. + * @default "$ctrl" */ controllerAs?: string; /** @@ -1710,14 +1702,12 @@ declare module angular { * Define DOM attribute binding to component properties. Component properties are always bound to the component * controller and not to the scope. */ - bindings?: any; + bindings?: {[binding: string]: string}; /** * Whether transclusion is enabled. Enabled by default. */ - transclude?: boolean; - require? : Object; - $canActivate?: () => boolean; - $routeConfig?: RouteDefinition[]; + transclude?: boolean | string | {[slot: string]: string}; + require?: string | string[] | {[controller: string]: string}; } interface IComponentTemplateFn { @@ -1753,6 +1743,12 @@ declare module angular { ( templateElement: IAugmentedJQuery, templateAttributes: IAttributes, + /** + * @deprecated + * Note: The transclude function that is passed to the compile function is deprecated, + * as it e.g. does not know about the right outer scope. Please use the transclude function + * that is passed to the link function instead. + */ transclude: ITranscludeFunction ): IDirectivePrePost; } @@ -1761,19 +1757,29 @@ declare module angular { compile?: IDirectiveCompileFn; controller?: any; controllerAs?: string; - bindToController?: boolean|Object; + /** + * @deprecated + * Deprecation warning: although bindings for non-ES6 class controllers are currently bound to this before + * the controller constructor is called, this use is now deprecated. Please place initialization code that + * relies upon bindings inside a $onInit method on the controller, instead. + */ + bindToController?: boolean | Object; link?: IDirectiveLinkFn | IDirectivePrePost; + multiElement?: boolean; name?: string; priority?: number; + /** + * @deprecated + */ replace?: boolean; - require? : any; + require?: string | string[] | {[controller: string]: string}; restrict?: string; - scope?: any; + scope?: boolean | Object; template?: string | Function; templateNamespace?: string; templateUrl?: string | Function; terminal?: boolean; - transclude?: any; + transclude?: boolean | string | {[slot: string]: string}; } /** diff --git a/angularjs/legacy/angular-1.4.d.ts b/angularjs/legacy/angular-1.4.d.ts new file mode 100644 index 0000000000..48249ac582 --- /dev/null +++ b/angularjs/legacy/angular-1.4.d.ts @@ -0,0 +1,1877 @@ +// Type definitions for Angular JS 1.4+ +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +declare var angular: angular.IAngularStatic; + +// Support for painless dependency injection +interface Function { + $inject?: string[]; +} + +// Collapse angular into ng +import ng = angular; +// Support AMD require +declare module 'angular' { + export = angular; +} + +/////////////////////////////////////////////////////////////////////////////// +// ng module (angular.js) +/////////////////////////////////////////////////////////////////////////////// +declare module angular { + + // not directly implemented, but ensures that constructed class implements $get + interface IServiceProviderClass { + new (...args: any[]): IServiceProvider; + } + + interface IServiceProviderFactory { + (...args: any[]): IServiceProvider; + } + + // All service providers extend this interface + interface IServiceProvider { + $get: any; + } + + interface IAngularBootstrapConfig { + strictDi?: boolean; + debugInfoEnabled?: boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // see http://docs.angularjs.org/api + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + bind(context: any, fn: Function, ...args: any[]): Function; + + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a config block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: string|Element|JQuery|Document, modules?: (string|Function|any[])[], config?: IAngularBootstrapConfig): auto.IInjectorService; + + /** + * Creates a deep copy of source, which should be an object or an array. + * + * - If no destination is supplied, a copy of the object or array is created. + * - If a destination is provided, all of its elements (for array) or properties (for objects) are deleted and then all elements/properties from the source are copied to it. + * - If source is not an object or array (inc. null and undefined), source is returned. + * - If source is identical to 'destination' an exception will be thrown. + * + * @param source The source that will be used to make a copy. Can be any type, including primitives, null, and undefined. + * @param destination Destination into which the source is copied. If provided, must be of the same type as source. + */ + copy(source: T, destination?: T): T; + + /** + * Wraps a raw DOM element or HTML string as a jQuery element. + * + * If jQuery is available, angular.element is an alias for the jQuery function. If jQuery is not available, angular.element delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite." + */ + element: IAugmentedJQueryStatic; + equals(value1: any, value2: any): boolean; + extend(destination: any, ...sources: any[]): any; + + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: T[], iterator: (value: T, key: number) => any, context?: any): any; + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any; + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any; + + fromJson(json: string): any; + identity(arg?: T): T; + injector(modules?: any[], strictDi?: boolean): auto.IInjectorService; + isArray(value: any): boolean; + isDate(value: any): boolean; + isDefined(value: any): boolean; + isElement(value: any): boolean; + isFunction(value: any): boolean; + isNumber(value: any): boolean; + isObject(value: any): boolean; + isString(value: any): boolean; + isUndefined(value: any): boolean; + lowercase(str: string): string; + + /** + * Deeply extends the destination object dst by copying own enumerable properties from the src object(s) to dst. You can specify multiple src objects. If you want to preserve original objects, you can do so by passing an empty object as the target: var object = angular.merge({}, object1, object2). + * + * Unlike extend(), merge() recursively descends into object properties of source objects, performing a deep copy. + * + * @param dst Destination object. + * @param src Source object(s). + */ + merge(dst: any, ...src: any[]): any; + + /** + * The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism. + * + * When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved. + * + * @param name The name of the module to create or retrieve. + * @param requires The names of modules this module depends on. If specified then new module is being created. If unspecified then the module is being retrieved for further configuration. + * @param configFn Optional configuration function for the module. + */ + module( + name: string, + requires?: string[], + configFn?: Function): IModule; + + noop(...args: any[]): void; + reloadWithDebugInfo(): void; + toJson(obj: any, pretty?: boolean): string; + uppercase(str: string): string; + version: { + full: string; + major: number; + minor: number; + dot: number; + codeName: string; + }; + + /** + * If window.name contains prefix NG_DEFER_BOOTSTRAP! when angular.bootstrap is called, the bootstrap process will be paused until angular.resumeBootstrap() is called. + * @param extraModules An optional array of modules that should be added to the original list of modules that the app was about to be bootstrapped with. + */ + resumeBootstrap?(extraModules?: string[]): ng.auto.IInjectorService; + } + + /////////////////////////////////////////////////////////////////////////// + // Module + // see http://docs.angularjs.org/api/angular.Module + /////////////////////////////////////////////////////////////////////////// + interface IModule { + animation(name: string, animationFactory: Function): IModule; + animation(name: string, inlineAnnotatedFunction: any[]): IModule; + animation(object: Object): IModule; + /** + * Use this method to register a component. + * + * @param name The name of the component. + * @param options A definition object passed into the component. + */ + component(name: string, options: IComponentOptions): IModule; + /** + * Use this method to register work which needs to be performed on module loading. + * + * @param configFn Execute this function on module load. Useful for service configuration. + */ + config(configFn: Function): IModule; + /** + * Use this method to register work which needs to be performed on module loading. + * + * @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration. + */ + config(inlineAnnotatedFunction: any[]): IModule; + config(object: Object): IModule; + /** + * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator. + * + * @param name The name of the constant. + * @param value The constant value. + */ + constant(name: string, value: any): IModule; + constant(object: Object): IModule; + /** + * The $controller service is used by Angular to create new controllers. + * + * This provider allows controller registration via the register method. + * + * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. + * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). + */ + controller(name: string, controllerConstructor: Function): IModule; + /** + * The $controller service is used by Angular to create new controllers. + * + * This provider allows controller registration via the register method. + * + * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. + * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). + */ + controller(name: string, inlineAnnotatedConstructor: any[]): IModule; + controller(object: Object): IModule; + /** + * Register a new directive with the compiler. + * + * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind) + * @param directiveFactory An injectable directive factory function. + */ + directive(name: string, directiveFactory: IDirectiveFactory): IModule; + /** + * Register a new directive with the compiler. + * + * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind) + * @param directiveFactory An injectable directive factory function. + */ + directive(name: string, inlineAnnotatedFunction: any[]): IModule; + directive(object: Object): IModule; + /** + * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider. + * + * @param name The name of the instance. + * @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). + */ + factory(name: string, $getFn: Function): IModule; + /** + * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider. + * + * @param name The name of the instance. + * @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). + */ + factory(name: string, inlineAnnotatedFunction: any[]): IModule; + factory(object: Object): IModule; + filter(name: string, filterFactoryFunction: Function): IModule; + filter(name: string, inlineAnnotatedFunction: any[]): IModule; + filter(object: Object): IModule; + provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule; + provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule; + provider(name: string, inlineAnnotatedConstructor: any[]): IModule; + provider(name: string, providerObject: IServiceProvider): IModule; + provider(object: Object): IModule; + /** + * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests. + */ + run(initializationFunction: Function): IModule; + /** + * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests. + */ + run(inlineAnnotatedFunction: any[]): IModule; + service(name: string, serviceConstructor: Function): IModule; + service(name: string, inlineAnnotatedConstructor: any[]): IModule; + service(object: Object): IModule; + /** + * Register a value service with the $injector, such as a string, a number, an array, an object or a function. This is short for registering a service where its provider's $get property is a factory function that takes no arguments and returns the value service. + + Value services are similar to constant services, except that they cannot be injected into a module configuration function (see config) but they can be overridden by an Angular decorator. + * + * @param name The name of the instance. + * @param value The value. + */ + value(name: string, value: any): IModule; + value(object: Object): IModule; + + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. + * @param name The name of the service to decorate + * @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. + */ + decorator(name:string, decoratorConstructor: Function): IModule; + decorator(name:string, inlineAnnotatedConstructor: any[]): IModule; + + // Properties + name: string; + requires: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // Attributes + // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes + /////////////////////////////////////////////////////////////////////////// + interface IAttributes { + /** + * 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; + + /** + * Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with x- or data-) to its normalized, camelCase form. + * + * Also there is special case for Moz prefix starting with upper case letter. + * + * For further information check out the guide on @see https://docs.angularjs.org/guide/directive#matching-directives + */ + $normalize(name: string): string; + + /** + * 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 + * the class removal. + */ + $removeClass(classVal: string): void; + + /** + * Set DOM element attribute value. + */ + $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 + * interpolated value changes. + */ + $observe(name: string, fn: (value?: T) => any): Function; + + /** + * 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; + } + + /** + * form.FormController - type in module ng + * see https://docs.angularjs.org/api/ng/type/form.FormController + */ + interface IFormController { + + /** + * Indexer which should return ng.INgModelController for most properties but cannot because of "All named properties must be assignable to string indexer type" constraint - see https://github.com/Microsoft/TypeScript/issues/272 + */ + [name: string]: any; + + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + $submitted: boolean; + $error: any; + $addControl(control: INgModelController): void; + $removeControl(control: INgModelController): void; + $setValidity(validationErrorKey: string, isValid: boolean, control: INgModelController): void; + $setDirty(): void; + $setPristine(): void; + $commitViewValue(): void; + $rollbackViewValue(): void; + $setSubmitted(): void; + $setUntouched(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // NgModelController + // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController + /////////////////////////////////////////////////////////////////////////// + interface INgModelController { + $render(): void; + $setValidity(validationErrorKey: string, isValid: boolean): void; + // Documentation states viewValue and modelValue to be a string but other + // types do work and it's common to use them. + $setViewValue(value: any, trigger?: string): void; + $setPristine(): void; + $setDirty(): void; + $validate(): void; + $setTouched(): void; + $setUntouched(): void; + $rollbackViewValue(): void; + $commitViewValue(): void; + $isEmpty(value: any): boolean; + + $viewValue: any; + + $modelValue: any; + + $parsers: IModelParser[]; + $formatters: IModelFormatter[]; + $viewChangeListeners: IModelViewChangeListener[]; + $error: any; + $name: string; + + $touched: boolean; + $untouched: boolean; + + $validators: IModelValidators; + $asyncValidators: IAsyncModelValidators; + + $pending: any; + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + } + + interface IModelValidators { + /** + * viewValue is any because it can be an object that is called in the view like $viewValue.name:$viewValue.subName + */ + [index: string]: (modelValue: any, viewValue: any) => boolean; + } + + interface IAsyncModelValidators { + [index: string]: (modelValue: any, viewValue: any) => IPromise; + } + + interface IModelParser { + (value: any): any; + } + + interface IModelFormatter { + (value: any): any; + } + + interface IModelViewChangeListener { + (): void; + } + + /** + * $rootScope - $rootScopeProvider - service in module ng + * see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope + */ + interface IRootScopeService { + [index: string]: any; + + $apply(): any; + $apply(exp: string): any; + $apply(exp: (scope: IScope) => any): any; + + $applyAsync(): any; + $applyAsync(exp: string): any; + $applyAsync(exp: (scope: IScope) => any): any; + + /** + * Dispatches an event name downwards to all child scopes (and their children) notifying the registered $rootScope.Scope listeners. + * + * The event life cycle starts at the scope on which $broadcast was called. All listeners listening for name event on this scope get notified. Afterwards, the event propagates to all direct and indirect scopes of the current scope and calls all registered listeners along the way. The event cannot be canceled. + * + * Any exception emitted from the listeners will be passed onto the $exceptionHandler service. + * + * @param name Event name to broadcast. + * @param args Optional one or more arguments which will be passed onto the event listeners. + */ + $broadcast(name: string, ...args: any[]): IAngularEvent; + $destroy(): void; + $digest(): void; + /** + * Dispatches an event name upwards through the scope hierarchy notifying the registered $rootScope.Scope listeners. + * + * The event life cycle starts at the scope on which $emit was called. All listeners listening for name event on this scope get notified. Afterwards, the event traverses upwards toward the root scope and calls all registered listeners along the way. The event will stop propagating if one of the listeners cancels it. + * + * Any exception emitted from the listeners will be passed onto the $exceptionHandler service. + * + * @param name Event name to emit. + * @param args Optional one or more arguments which will be passed onto the event listeners. + */ + $emit(name: string, ...args: any[]): IAngularEvent; + + $eval(): any; + $eval(expression: string, locals?: Object): any; + $eval(expression: (scope: IScope) => any, locals?: Object): any; + + $evalAsync(): void; + $evalAsync(expression: string): void; + $evalAsync(expression: (scope: IScope) => any): void; + + // Defaults to false by the implementation checking strategy + $new(isolate?: boolean, parent?: IScope): IScope; + + /** + * Listens on events of a given type. See $emit for discussion of event life cycle. + * + * The event listener function format is: function(event, args...). + * + * @param name Event name to listen on. + * @param listener Function to call when the event is emitted. + */ + $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; + + $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: string, listener?: (newValue: T, oldValue: T, scope: IScope) => any, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => T, listener?: (newValue: T, oldValue: T, scope: IScope) => any, objectEquality?: boolean): Function; + + $watchCollection(watchExpression: string, listener: (newValue: T, oldValue: T, scope: IScope) => any): Function; + $watchCollection(watchExpression: (scope: IScope) => T, listener: (newValue: T, oldValue: T, scope: IScope) => any): Function; + + $watchGroup(watchExpressions: any[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + $watchGroup(watchExpressions: { (scope: IScope): any }[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + + $parent: IScope; + $root: IRootScopeService; + $id: number; + + // Hidden members + $$isolateBindings: any; + $$phase: any; + } + + interface IScope extends IRootScopeService { } + + /** + * $scope for ngRepeat directive. + * see https://docs.angularjs.org/api/ng/directive/ngRepeat + */ + interface IRepeatScope extends IScope { + + /** + * iterator offset of the repeated element (0..length-1). + */ + $index: number; + + /** + * true if the repeated element is first in the iterator. + */ + $first: boolean; + + /** + * true if the repeated element is between the first and last in the iterator. + */ + $middle: boolean; + + /** + * true if the repeated element is last in the iterator. + */ + $last: boolean; + + /** + * true if the iterator position $index is even (otherwise false). + */ + $even: boolean; + + /** + * true if the iterator position $index is odd (otherwise false). + */ + $odd: boolean; + + } + + interface IAngularEvent { + /** + * the scope on which the event was $emit-ed or $broadcast-ed. + */ + targetScope: IScope; + /** + * the scope that is currently handling the event. Once the event propagates through the scope hierarchy, this property is set to null. + */ + currentScope: IScope; + /** + * name of the event. + */ + name: string; + /** + * calling stopPropagation function will cancel further event propagation (available only for events that were $emit-ed). + */ + stopPropagation?: Function; + /** + * calling preventDefault sets defaultPrevented flag to true. + */ + preventDefault: Function; + /** + * true if preventDefault was called. + */ + defaultPrevented: boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // WindowService + // see http://docs.angularjs.org/api/ng.$window + /////////////////////////////////////////////////////////////////////////// + interface IWindowService extends Window { + [key: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // BrowserService + // TODO undocumented, so we need to get it from the source code + /////////////////////////////////////////////////////////////////////////// + interface IBrowserService { + defer: angular.ITimeoutService; + [key: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ng.$timeout + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + (delay?: number, invokeApply?: boolean): IPromise; + (fn: (...args: any[]) => T, delay?: number, invokeApply?: boolean, ...args: any[]): IPromise; + cancel(promise?: IPromise): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // IntervalService + // see http://docs.angularjs.org/api/ng.$interval + /////////////////////////////////////////////////////////////////////////// + interface IIntervalService { + (func: Function, delay: number, count?: number, invokeApply?: boolean, ...args: any[]): IPromise; + cancel(promise: IPromise): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // AnimateProvider + // see http://docs.angularjs.org/api/ng/provider/$animateProvider + /////////////////////////////////////////////////////////////////////////// + interface IAnimateProvider { + /** + * Registers a new injectable animation factory function. + * + * @param name The name of the animation. + * @param factory The factory function that will be executed to return the animation object. + */ + register(name: string, factory: () => IAnimateCallbackObject): void; + + /** + * Gets and/or sets the CSS class expression that is checked when performing an animation. + * + * @param expression The className expression which will be checked against all animations. + * @returns The current CSS className expression value. If null then there is no expression value. + */ + classNameFilter(expression?: RegExp): RegExp; + } + + /** + * The animation object which contains callback functions for each event that is expected to be animated. + */ + interface IAnimateCallbackObject { + eventFn(element: Node, doneFn: () => void): Function; + } + + /** + * $filter - $filterProvider - service in module ng + * + * Filters are used for formatting data displayed to the user. + * + * see https://docs.angularjs.org/api/ng/service/$filter + */ + interface IFilterService { + (name: 'filter'): IFilterFilter; + (name: 'currency'): IFilterCurrency; + (name: 'number'): IFilterNumber; + (name: 'date'): IFilterDate; + (name: 'json'): IFilterJson; + (name: 'lowercase'): IFilterLowercase; + (name: 'uppercase'): IFilterUppercase; + (name: 'limitTo'): IFilterLimitTo; + (name: 'orderBy'): IFilterOrderBy; + /** + * Usage: + * $filter(name); + * + * @param name Name of the filter function to retrieve + */ + (name: string): T; + } + + interface IFilterFilter { + (array: T[], expression: string | IFilterFilterPatternObject | IFilterFilterPredicateFunc, comparator?: IFilterFilterComparatorFunc|boolean): T[]; + } + + interface IFilterFilterPatternObject { + [name: string]: any; + } + + interface IFilterFilterPredicateFunc { + (value: T, index: number, array: T[]): boolean; + } + + interface IFilterFilterComparatorFunc { + (actual: T, expected: T): boolean; + } + + interface IFilterCurrency { + /** + * Formats a number as a currency (ie $1,234.56). When no currency symbol is provided, default symbol for current locale is used. + * @param amount Input to filter. + * @param symbol Currency symbol or identifier to be displayed. + * @param fractionSize Number of decimal places to round the amount to, defaults to default max fraction size for current locale + * @return Formatted number + */ + (amount: number, symbol?: string, fractionSize?: number): string; + } + + interface IFilterNumber { + /** + * Formats a number as text. + * @param number Number to format. + * @param fractionSize Number of decimal places to round the number to. If this is not provided then the fraction size is computed from the current locale's number formatting pattern. In the case of the default locale, it will be 3. + * @return Number rounded to decimalPlaces and places a “,” after each third digit. + */ + (value: number|string, fractionSize?: number|string): string; + } + + interface IFilterDate { + /** + * Formats date to a string based on the requested format. + * + * @param date Date to format either as Date object, milliseconds (string or number) or various ISO 8601 datetime string formats (e.g. yyyy-MM-ddTHH:mm:ss.sssZ and its shorter versions like yyyy-MM-ddTHH:mmZ, yyyy-MM-dd or yyyyMMddTHHmmssZ). If no timezone is specified in the string input, the time is considered to be in the local timezone. + * @param format Formatting rules (see Description). If not specified, mediumDate is used. + * @param timezone Timezone to be used for formatting. It understands UTC/GMT and the continental US time zone abbreviations, but for general use, use a time zone offset, for example, '+0430' (4 hours, 30 minutes east of the Greenwich meridian) If not specified, the timezone of the browser will be used. + * @return Formatted string or the input if input is not recognized as date/millis. + */ + (date: Date | number | string, format?: string, timezone?: string): string; + } + + interface IFilterJson { + /** + * Allows you to convert a JavaScript object into JSON string. + * @param object Any JavaScript object (including arrays and primitive types) to filter. + * @param spacing The number of spaces to use per indentation, defaults to 2. + * @return JSON string. + */ + (object: any, spacing?: number): string; + } + + interface IFilterLowercase { + /** + * Converts string to lowercase. + */ + (value: string): string; + } + + interface IFilterUppercase { + /** + * Converts string to uppercase. + */ + (value: string): string; + } + + interface IFilterLimitTo { + /** + * Creates a new array containing only a specified number of elements. The elements are taken from either the beginning or the end of the source array, string or number, as specified by the value and sign (positive or negative) of limit. + * @param input Source array to be limited. + * @param limit The length of the returned array. If the limit number is positive, limit number of items from the beginning of the source array/string are copied. If the number is negative, limit number of items from the end of the source array are copied. The limit will be trimmed if it exceeds array.length. If limit is undefined, the input will be returned unchanged. + * @param begin Index at which to begin limitation. As a negative index, begin indicates an offset from the end of input. Defaults to 0. + * @return A new sub-array of length limit or less if input array had less than limit elements. + */ + (input: T[], limit: string|number, begin?: string|number): T[]; + /** + * Creates a new string containing only a specified number of elements. The elements are taken from either the beginning or the end of the source string or number, as specified by the value and sign (positive or negative) of limit. If a number is used as input, it is converted to a string. + * @param input Source string or number to be limited. + * @param limit The length of the returned string. If the limit number is positive, limit number of items from the beginning of the source string are copied. If the number is negative, limit number of items from the end of the source string are copied. The limit will be trimmed if it exceeds input.length. If limit is undefined, the input will be returned unchanged. + * @param begin Index at which to begin limitation. As a negative index, begin indicates an offset from the end of input. Defaults to 0. + * @return A new substring of length limit or less if input had less than limit elements. + */ + (input: string|number, limit: string|number, begin?: string|number): string; + } + + interface IFilterOrderBy { + /** + * Orders a specified array by the expression predicate. It is ordered alphabetically for strings and numerically for numbers. Note: if you notice numbers are not being sorted as expected, make sure they are actually being saved as numbers and not strings. + * @param array The array to sort. + * @param expression A predicate to be used by the comparator to determine the order of elements. + * @param reverse Reverse the order of the array. + * @return Reverse the order of the array. + */ + (array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean): T[]; + } + + /** + * $filterProvider - $filter - provider in module ng + * + * Filters are just functions which transform input to an output. However filters need to be Dependency Injected. To achieve this a filter definition consists of a factory function which is annotated with dependencies and is responsible for creating a filter function. + * + * see https://docs.angularjs.org/api/ng/provider/$filterProvider + */ + interface IFilterProvider extends IServiceProvider { + /** + * register(name); + * + * @param name Name of the filter function, or an object map of filters where the keys are the filter names and the values are the filter factories. Note: Filter names must be valid angular Expressions identifiers, such as uppercase or orderBy. Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace your filters, then you can use capitalization (myappSubsectionFilterx) or underscores (myapp_subsection_filterx). + */ + register(name: string | {}): IServiceProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // LocaleService + // see http://docs.angularjs.org/api/ng.$locale + /////////////////////////////////////////////////////////////////////////// + interface ILocaleService { + id: string; + + // These are not documented + // Check angular's i18n files for exemples + NUMBER_FORMATS: ILocaleNumberFormatDescriptor; + DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor; + pluralCat: (num: any) => string; + } + + interface ILocaleNumberFormatDescriptor { + DECIMAL_SEP: string; + GROUP_SEP: string; + PATTERNS: ILocaleNumberPatternDescriptor[]; + CURRENCY_SYM: string; + } + + interface ILocaleNumberPatternDescriptor { + minInt: number; + minFrac: number; + maxFrac: number; + posPre: string; + posSuf: string; + negPre: string; + negSuf: string; + gSize: number; + lgSize: number; + } + + interface ILocaleDateTimeFormatDescriptor { + MONTH: string[]; + SHORTMONTH: string[]; + DAY: string[]; + SHORTDAY: string[]; + AMPMS: string[]; + medium: string; + short: string; + fullDate: string; + longDate: string; + mediumDate: string; + shortDate: string; + mediumTime: string; + shortTime: string; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ng.$log + // see http://docs.angularjs.org/api/ng.$logProvider + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + debug: ILogCall; + error: ILogCall; + info: ILogCall; + log: ILogCall; + warn: ILogCall; + } + + interface ILogProvider extends IServiceProvider { + debugEnabled(): boolean; + debugEnabled(enabled: boolean): ILogProvider; + } + + // We define this as separate interface so we can reopen it later for + // the ngMock module. + interface ILogCall { + (...args: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // ParseService + // see http://docs.angularjs.org/api/ng.$parse + // see http://docs.angularjs.org/api/ng.$parseProvider + /////////////////////////////////////////////////////////////////////////// + interface IParseService { + (expression: string): ICompiledExpression; + } + + interface IParseProvider { + logPromiseWarnings(): boolean; + logPromiseWarnings(value: boolean): IParseProvider; + + unwrapPromises(): boolean; + unwrapPromises(value: boolean): IParseProvider; + } + + interface ICompiledExpression { + (context: any, locals?: any): any; + + literal: boolean; + constant: boolean; + + // If value is not provided, undefined is gonna be used since the implementation + // does not check the parameter. Let's force a value for consistency. If consumer + // whants to undefine it, pass the undefined value explicitly. + assign(context: any, value: any): any; + } + + /** + * $location - $locationProvider - service in module ng + * see https://docs.angularjs.org/api/ng/service/$location + */ + interface ILocationService { + absUrl(): string; + hash(): string; + hash(newHash: string): ILocationService; + host(): string; + + /** + * Return path of current url + */ + path(): string; + + /** + * Change path when called with parameter and return $location. + * Note: Path should always begin with forward slash (/), this method will add the forward slash if it is missing. + * + * @param path New path + */ + path(path: string): ILocationService; + + port(): number; + protocol(): string; + replace(): ILocationService; + + /** + * Return search part (as object) of current url + */ + search(): any; + + /** + * Change search part when called with parameter and return $location. + * + * @param search When called with a single argument the method acts as a setter, setting the search component of $location to the specified value. + * + * If the argument is a hash object containing an array of values, these values will be encoded as duplicate search parameters in the url. + */ + search(search: any): ILocationService; + + /** + * Change search part when called with parameter and return $location. + * + * @param search New search params + * @param paramValue If search is a string or a Number, then paramValue will override only a single search property. If paramValue is null, the property specified via the first argument will be deleted. If paramValue is an array, it will override the property of the search component of $location specified via the first argument. If paramValue is true, the property specified via the first argument will be added with no value nor trailing equal sign. + */ + search(search: string, paramValue: string|number|string[]|boolean): ILocationService; + + state(): any; + state(state: any): ILocationService; + url(): string; + url(url: string): ILocationService; + } + + interface ILocationProvider extends IServiceProvider { + hashPrefix(): string; + hashPrefix(prefix: string): ILocationProvider; + html5Mode(): boolean; + + // Documentation states that parameter is string, but + // implementation tests it as boolean, which makes more sense + // since this is a toggler + html5Mode(active: boolean): ILocationProvider; + html5Mode(mode: { enabled?: boolean; requireBase?: boolean; rewriteLinks?: boolean; }): ILocationProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // DocumentService + // see http://docs.angularjs.org/api/ng.$document + /////////////////////////////////////////////////////////////////////////// + interface IDocumentService extends IAugmentedJQuery {} + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ng.$exceptionHandler + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerService { + (exception: Error, cause?: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // RootElementService + // see http://docs.angularjs.org/api/ng.$rootElement + /////////////////////////////////////////////////////////////////////////// + interface IRootElementService extends JQuery {} + + interface IQResolveReject { + (): void; + (value: T): void; + } + /** + * $q - service in module ng + * A promise/deferred implementation inspired by Kris Kowal's Q. + * See http://docs.angularjs.org/api/ng/service/$q + */ + interface IQService { + new (resolver: (resolve: IQResolveReject) => any): IPromise; + new (resolver: (resolve: IQResolveReject, reject: IQResolveReject) => any): IPromise; + (resolver: (resolve: IQResolveReject) => any): IPromise; + (resolver: (resolve: IQResolveReject, reject: IQResolveReject) => any): IPromise; + + /** + * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved. + * + * Returns a single promise that will be resolved with an array of values, each value corresponding to the promise at the same index in the promises array. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value. + * + * @param promises An array of promises. + */ + all(promises: IPromise[]): IPromise; + /** + * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved. + * + * Returns a single promise that will be resolved with a hash of values, each value corresponding to the promise at the same key in the promises hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value. + * + * @param promises A hash of promises. + */ + all(promises: { [id: string]: IPromise; }): IPromise<{ [id: string]: any; }>; + all(promises: { [id: string]: IPromise; }): IPromise; + /** + * Creates a Deferred object which represents a task which will finish in the future. + */ + defer(): IDeferred; + /** + * Creates a promise that is resolved as rejected with the specified reason. This api should be used to forward rejection in a chain of promises. If you are dealing with the last promise in a promise chain, you don't need to worry about it. + * + * When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of reject as the throw keyword in JavaScript. This also means that if you "catch" an error via a promise error callback and you want to forward the error to the promise derived from the current promise, you have to "rethrow" the error by returning a rejection constructed via reject. + * + * @param reason Constant, message, exception or an object representing the rejection reason. + */ + reject(reason?: any): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + * + * @param value Value or a promise + */ + resolve(value: IPromise|T): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + */ + resolve(): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + * + * @param value Value or a promise + */ + when(value: IPromise|T): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + */ + when(): IPromise; + } + + interface IPromise { + /** + * Regardless of when the promise was or will be resolved or rejected, then calls one of the success or error callbacks asynchronously as soon as the result is available. The callbacks are called with a single argument: the result or rejection reason. Additionally, the notify callback may be called zero or more times to provide a progress indication, before the promise is resolved or rejected. + * The successCallBack may return IPromise for when a $q.reject() needs to be returned + * This method returns a new promise which is resolved or rejected via the return value of the successCallback, errorCallback. It also notifies via the return value of the notifyCallback method. The promise can not be resolved or rejected from the notifyCallback method. + */ + then(successCallback: (promiseValue: T) => IPromise|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise; + + /** + * Shorthand for promise.then(null, errorCallback) + */ + catch(onRejected: (reason: any) => IPromise|TResult): IPromise; + + /** + * Allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful to release resources or do some clean-up that needs to be done whether the promise was rejected or resolved. See the full specification for more information. + * + * Because finally is a reserved word in JavaScript and reserved keywords are not supported as property names by ES3, you'll need to invoke the method like promise['finally'](callback) to make your code IE8 and Android 2.x compatible. + */ + finally(finallyCallback: () => any): IPromise; + } + + interface IDeferred { + resolve(value?: T|IPromise): void; + reject(reason?: any): void; + notify(state?: any): void; + promise: IPromise; + } + + /////////////////////////////////////////////////////////////////////////// + // AnchorScrollService + // see http://docs.angularjs.org/api/ng.$anchorScroll + /////////////////////////////////////////////////////////////////////////// + interface IAnchorScrollService { + (): void; + (hash: string): void; + yOffset: any; + } + + interface IAnchorScrollProvider extends IServiceProvider { + disableAutoScrolling(): void; + } + + /** + * $cacheFactory - service in module ng + * + * Factory that constructs Cache objects and gives access to them. + * + * see https://docs.angularjs.org/api/ng/service/$cacheFactory + */ + interface ICacheFactoryService { + /** + * Factory that constructs Cache objects and gives access to them. + * + * @param cacheId Name or id of the newly created cache. + * @param optionsMap Options object that specifies the cache behavior. Properties: + * + * capacity — turns the cache into LRU cache. + */ + (cacheId: string, optionsMap?: { capacity?: number; }): ICacheObject; + + /** + * Get information about all the caches that have been created. + * @returns key-value map of cacheId to the result of calling cache#info + */ + info(): any; + + /** + * Get access to a cache object by the cacheId used when it was created. + * + * @param cacheId Name or id of a cache to access. + */ + get(cacheId: string): ICacheObject; + } + + /** + * $cacheFactory.Cache - type in module ng + * + * A cache object used to store and retrieve data, primarily used by $http and the script directive to cache templates and other data. + * + * see https://docs.angularjs.org/api/ng/type/$cacheFactory.Cache + */ + interface ICacheObject { + /** + * Retrieve information regarding a particular Cache. + */ + info(): { + /** + * the id of the cache instance + */ + id: string; + + /** + * the number of entries kept in the cache instance + */ + size: number; + + //...: any additional properties from the options object when creating the cache. + }; + + /** + * Inserts a named entry into the Cache object to be retrieved later, and incrementing the size of the cache if the key was not already present in the cache. If behaving like an LRU cache, it will also remove stale entries from the set. + * + * It will not insert undefined values into the cache. + * + * @param key the key under which the cached data is stored. + * @param value the value to store alongside the key. If it is undefined, the key will not be stored. + */ + put(key: string, value?: T): T; + + /** + * Retrieves named data stored in the Cache object. + * + * @param key the key of the data to be retrieved + */ + get(key: string): T; + + /** + * Removes an entry from the Cache object. + * + * @param key the key of the entry to be removed + */ + remove(key: string): void; + + /** + * Clears the cache object of any entries. + */ + removeAll(): void; + + /** + * Destroys the Cache object entirely, removing it from the $cacheFactory set. + */ + destroy(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CompileService + // see http://docs.angularjs.org/api/ng.$compile + // see http://docs.angularjs.org/api/ng.$compileProvider + /////////////////////////////////////////////////////////////////////////// + interface ICompileService { + (element: string, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: Element, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: JQuery, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + } + + interface ICompileProvider extends IServiceProvider { + directive(name: string, directiveFactory: Function): ICompileProvider; + + // Undocumented, but it is there... + directive(directivesMap: any): ICompileProvider; + + aHrefSanitizationWhitelist(): RegExp; + aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider; + + imgSrcSanitizationWhitelist(): RegExp; + imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider; + + debugInfoEnabled(enabled?: boolean): any; + } + + interface ICloneAttachFunction { + // Let's hint but not force cloneAttachFn's signature + (clonedElement?: JQuery, scope?: IScope): any; + } + + // This corresponds to the "publicLinkFn" returned by $compile. + interface ITemplateLinkingFunction { + (scope: IScope, cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; + } + + // This corresponds to $transclude (and also the transclude function passed to link). + interface ITranscludeFunction { + // If the scope is provided, then the cloneAttachFn must be as well. + (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery; + // If one argument is provided, then it's assumed to be the cloneAttachFn. + (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; + } + + /////////////////////////////////////////////////////////////////////////// + // ControllerService + // see http://docs.angularjs.org/api/ng.$controller + // see http://docs.angularjs.org/api/ng.$controllerProvider + /////////////////////////////////////////////////////////////////////////// + interface IControllerService { + // Although the documentation doesn't state this, locals are optional + (controllerConstructor: new (...args: any[]) => T, locals?: any, bindToController?: any): T; + (controllerConstructor: Function, locals?: any, bindToController?: any): T; + (controllerName: string, locals?: any, bindToController?: any): T; + } + + interface IControllerProvider extends IServiceProvider { + register(name: string, controllerConstructor: Function): void; + register(name: string, dependencyAnnotatedConstructor: any[]): void; + allowGlobals(): void; + } + + /** + * HttpService + * see http://docs.angularjs.org/api/ng/service/$http + */ + interface IHttpService { + /** + * Object describing the request to be made and how it should be processed. + */ + (config: IRequestConfig): IHttpPromise; + + /** + * Shortcut method to perform GET request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + get(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform DELETE request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + delete(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform HEAD request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + head(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform JSONP request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + jsonp(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform POST request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param data Request content + * @param config Optional configuration object + */ + post(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform PUT request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param data Request content + * @param config Optional configuration object + */ + put(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform PATCH request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param data Request content + * @param config Optional configuration object + */ + patch(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations. + */ + defaults: IHttpProviderDefaults; + + /** + * Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes. + */ + pendingRequests: IRequestConfig[]; + } + + /** + * Object describing the request to be made and how it should be processed. + * see http://docs.angularjs.org/api/ng/service/$http#usage + */ + interface IRequestShortcutConfig extends IHttpProviderDefaults { + /** + * {Object.} + * Map of strings or objects which will be turned to ?key1=value1&key2=value2 after the url. If the value is not a string, it will be JSONified. + */ + params?: any; + + /** + * {string|Object} + * Data to be sent as the request message data. + */ + data?: any; + + /** + * Timeout in milliseconds, or promise that should abort the request when resolved. + */ + timeout?: number|IPromise; + + /** + * See [XMLHttpRequest.responseType]https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#xmlhttprequest-responsetype + */ + responseType?: string; + } + + /** + * Object describing the request to be made and how it should be processed. + * see http://docs.angularjs.org/api/ng/service/$http#usage + */ + interface IRequestConfig extends IRequestShortcutConfig { + /** + * HTTP method (e.g. 'GET', 'POST', etc) + */ + method: string; + /** + * Absolute or relative URL of the resource that is being requested. + */ + url: string; + } + + interface IHttpHeadersGetter { + (): { [name: string]: string; }; + (headerName: string): string; + } + + interface IHttpPromiseCallback { + (data: T, status: number, headers: IHttpHeadersGetter, config: IRequestConfig): void; + } + + interface IHttpPromiseCallbackArg { + data?: T; + status?: number; + headers?: IHttpHeadersGetter; + config?: IRequestConfig; + statusText?: string; + } + + interface IHttpPromise extends IPromise> { + success(callback: IHttpPromiseCallback): IHttpPromise; + error(callback: IHttpPromiseCallback): IHttpPromise; + } + + // See the jsdoc for transformData() at https://github.com/angular/angular.js/blob/master/src/ng/http.js#L228 + interface IHttpRequestTransformer { + (data: any, headersGetter: IHttpHeadersGetter): any; + } + + // The definition of fields are the same as IHttpPromiseCallbackArg + interface IHttpResponseTransformer { + (data: any, headersGetter: IHttpHeadersGetter, status: number): any; + } + + interface IHttpRequestConfigHeaders { + [requestType: string]: string|(() => string); + common?: string|(() => string); + get?: string|(() => string); + post?: string|(() => string); + put?: string|(() => string); + patch?: string|(() => string); + } + + /** + * Object that controls the defaults for $http provider. Not all fields of IRequestShortcutConfig can be configured + * via defaults and the docs do not say which. The following is based on the inspection of the source code. + * https://docs.angularjs.org/api/ng/service/$http#defaults + * https://docs.angularjs.org/api/ng/service/$http#usage + * https://docs.angularjs.org/api/ng/provider/$httpProvider The properties section + */ + interface IHttpProviderDefaults { + /** + * {boolean|Cache} + * If true, a default $http cache will be used to cache the GET request, otherwise if a cache instance built with $cacheFactory, this cache will be used for caching. + */ + cache?: any; + + /** + * Transform function or an array of such functions. The transform function takes the http request body and + * headers and returns its transformed (typically serialized) version. + * @see {@link https://docs.angularjs.org/api/ng/service/$http#transforming-requests-and-responses} + */ + transformRequest?: IHttpRequestTransformer |IHttpRequestTransformer[]; + + /** + * Transform function or an array of such functions. The transform function takes the http response body and + * headers and returns its transformed (typically deserialized) version. + */ + transformResponse?: IHttpResponseTransformer | IHttpResponseTransformer[]; + + /** + * Map of strings or functions which return strings representing HTTP headers to send to the server. If the + * return value of a function is null, the header will not be sent. + * The key of the map is the request verb in lower case. The "common" key applies to all requests. + * @see {@link https://docs.angularjs.org/api/ng/service/$http#setting-http-headers} + */ + headers?: IHttpRequestConfigHeaders; + + /** Name of HTTP header to populate with the XSRF token. */ + xsrfHeaderName?: string; + + /** Name of cookie containing the XSRF token. */ + xsrfCookieName?: string; + + /** + * whether to to set the withCredentials flag on the XHR object. See [requests with credentials]https://developer.mozilla.org/en/http_access_control#section_5 for more information. + */ + withCredentials?: boolean; + + /** + * A function used to the prepare string representation of request parameters (specified as an object). If + * specified as string, it is interpreted as a function registered with the $injector. Defaults to + * $httpParamSerializer. + */ + paramSerializer?: string | ((obj: any) => string); + } + + interface IHttpInterceptor { + request?: (config: IRequestConfig) => IRequestConfig|IPromise; + requestError?: (rejection: any) => any; + response?: (response: IHttpPromiseCallbackArg) => IPromise|T; + responseError?: (rejection: any) => any; + } + + interface IHttpInterceptorFactory { + (...args: any[]): IHttpInterceptor; + } + + interface IHttpProvider extends IServiceProvider { + defaults: IHttpProviderDefaults; + + /** + * Register service factories (names or implementations) for interceptors which are called before and after + * each request. + */ + interceptors: (string|IHttpInterceptorFactory|(string|IHttpInterceptorFactory)[])[]; + useApplyAsync(): boolean; + useApplyAsync(value: boolean): IHttpProvider; + + /** + * + * @param {boolean=} value If true, `$http` will return a normal promise without the `success` and `error` methods. + * @returns {boolean|Object} If a value is specified, returns the $httpProvider for chaining. + * otherwise, returns the current configured value. + */ + useLegacyPromiseExtensions(value:boolean) : boolean | IHttpProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see http://docs.angularjs.org/api/ng.$httpBackend + // You should never need to use this service directly. + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + // XXX Perhaps define callback signature in the future + (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void; + } + + /////////////////////////////////////////////////////////////////////////// + // InterpolateService + // see http://docs.angularjs.org/api/ng.$interpolate + // see http://docs.angularjs.org/api/ng.$interpolateProvider + /////////////////////////////////////////////////////////////////////////// + interface IInterpolateService { + (text: string, mustHaveExpression?: boolean, trustedContext?: string, allOrNothing?: boolean): IInterpolationFunction; + endSymbol(): string; + startSymbol(): string; + } + + interface IInterpolationFunction { + (context: any): string; + } + + interface IInterpolateProvider extends IServiceProvider { + startSymbol(): string; + startSymbol(value: string): IInterpolateProvider; + endSymbol(): string; + endSymbol(value: string): IInterpolateProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // TemplateCacheService + // see http://docs.angularjs.org/api/ng.$templateCache + /////////////////////////////////////////////////////////////////////////// + interface ITemplateCacheService extends ICacheObject {} + + /////////////////////////////////////////////////////////////////////////// + // SCEService + // see http://docs.angularjs.org/api/ng.$sce + /////////////////////////////////////////////////////////////////////////// + interface ISCEService { + getTrusted(type: string, mayBeTrusted: any): any; + getTrustedCss(value: any): any; + getTrustedHtml(value: any): any; + getTrustedJs(value: any): any; + getTrustedResourceUrl(value: any): any; + getTrustedUrl(value: any): any; + parse(type: string, expression: string): (context: any, locals: any) => any; + parseAsCss(expression: string): (context: any, locals: any) => any; + parseAsHtml(expression: string): (context: any, locals: any) => any; + parseAsJs(expression: string): (context: any, locals: any) => any; + parseAsResourceUrl(expression: string): (context: any, locals: any) => any; + parseAsUrl(expression: string): (context: any, locals: any) => any; + trustAs(type: string, value: any): any; + trustAsHtml(value: any): any; + trustAsJs(value: any): any; + trustAsResourceUrl(value: any): any; + trustAsUrl(value: any): any; + isEnabled(): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // SCEProvider + // see http://docs.angularjs.org/api/ng.$sceProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEProvider extends IServiceProvider { + enabled(value: boolean): void; + } + + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateService + // see http://docs.angularjs.org/api/ng.$sceDelegate + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateService { + getTrusted(type: string, mayBeTrusted: any): any; + trustAs(type: string, value: any): any; + valueOf(value: any): any; + } + + + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateProvider + // see http://docs.angularjs.org/api/ng.$sceDelegateProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateProvider extends IServiceProvider { + resourceUrlBlacklist(blacklist: any[]): void; + resourceUrlWhitelist(whitelist: any[]): void; + resourceUrlBlacklist(): any[]; + resourceUrlWhitelist(): any[]; + } + + /** + * $templateRequest service + * see http://docs.angularjs.org/api/ng/service/$templateRequest + */ + interface ITemplateRequestService { + /** + * Downloads a template using $http and, upon success, stores the + * contents inside of $templateCache. + * + * If the HTTP request fails or the response data of the HTTP request is + * empty then a $compile error will be thrown (unless + * {ignoreRequestError} is set to true). + * + * @param tpl The template URL. + * @param ignoreRequestError Whether or not to ignore the exception + * when the request fails or the template is + * empty. + * + * @return A promise whose value is the template content. + */ + (tpl: string, ignoreRequestError?: boolean): IPromise; + /** + * total amount of pending template requests being downloaded. + * @type {number} + */ + totalPendingRequests: number; + } + + /////////////////////////////////////////////////////////////////////////// + // Component + // see http://angularjs.blogspot.com.br/2015/11/angularjs-15-beta2-and-14-releases.html + // and http://toddmotto.com/exploring-the-angular-1-5-component-method/ + /////////////////////////////////////////////////////////////////////////// + /** + * Runtime representation a type that a Component or other object is instances of. + * + * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by + * the `MyCustomComponent` constructor function. + */ + interface Type extends Function { + } + + /** + * `RouteDefinition` defines a route within a {@link RouteConfig} decorator. + * + * Supported keys: + * - `path` or `aux` (requires exactly one of these) + * - `component`, `loader`, `redirectTo` (requires exactly one of these) + * - `name` or `as` (optional) (requires exactly one of these) + * - `data` (optional) + * + * See also {@link Route}, {@link AsyncRoute}, {@link AuxRoute}, and {@link Redirect}. + */ + interface RouteDefinition { + path?: string; + aux?: string; + component?: Type | ComponentDefinition | string; + loader?: Function; + redirectTo?: any[]; + as?: string; + name?: string; + data?: any; + useAsDefault?: boolean; + } + + /** + * Represents either a component type (`type` is `component`) or a loader function + * (`type` is `loader`). + * + * See also {@link RouteDefinition}. + */ + interface ComponentDefinition { + type: string; + loader?: Function; + component?: Type; + } + + /** + * Component definition object (a simplified directive definition object) + */ + interface IComponentOptions { + /** + * Controller constructor function that should be associated with newly created scope or the name of a registered + * controller if passed as a string. Empty function by default. + */ + controller?: any; + /** + * An identifier name for a reference to the controller. If present, the controller will be published to scope under + * the controllerAs name. If not present, this will default to be the same as the component name. + */ + controllerAs?: string; + /** + * html template as a string or a function that returns an html template as a string which should be used as the + * contents of this component. Empty string by default. + * If template is a function, then it is injected with the following locals: + * $element - Current element + * $attrs - Current attributes object for the element + */ + template?: string | Function; + /** + * path or function that returns a path to an html template that should be used as the contents of this component. + * If templateUrl is a function, then it is injected with the following locals: + * $element - Current element + * $attrs - Current attributes object for the element + */ + templateUrl?: string | Function; + /** + * Define DOM attribute binding to component properties. Component properties are always bound to the component + * controller and not to the scope. + */ + bindings?: any; + /** + * Whether transclusion is enabled. Enabled by default. + */ + transclude?: boolean; + require? : Object; + $canActivate?: () => boolean; + $routeConfig?: RouteDefinition[]; + } + + interface IComponentTemplateFn { + ( $element?: IAugmentedJQuery, $attrs?: IAttributes ): string; + } + + /////////////////////////////////////////////////////////////////////////// + // Directive + // see http://docs.angularjs.org/api/ng.$compileProvider#directive + // and http://docs.angularjs.org/guide/directive + /////////////////////////////////////////////////////////////////////////// + + interface IDirectiveFactory { + (...args: any[]): IDirective; + } + + interface IDirectiveLinkFn { + ( + scope: IScope, + instanceElement: IAugmentedJQuery, + instanceAttributes: IAttributes, + controller: {}, + transclude: ITranscludeFunction + ): void; + } + + interface IDirectivePrePost { + pre?: IDirectiveLinkFn; + post?: IDirectiveLinkFn; + } + + interface IDirectiveCompileFn { + ( + templateElement: IAugmentedJQuery, + templateAttributes: IAttributes, + transclude: ITranscludeFunction + ): IDirectivePrePost; + } + + interface IDirective { + compile?: IDirectiveCompileFn; + controller?: any; + controllerAs?: string; + bindToController?: boolean|Object; + link?: IDirectiveLinkFn | IDirectivePrePost; + name?: string; + priority?: number; + replace?: boolean; + require? : any; + restrict?: string; + scope?: any; + template?: string | Function; + templateNamespace?: string; + templateUrl?: string | Function; + terminal?: boolean; + transclude?: any; + } + + /** + * angular.element + * when calling angular.element, angular returns a jQuery object, + * augmented with additional methods like e.g. scope. + * see: http://docs.angularjs.org/api/angular.element + */ + interface IAugmentedJQueryStatic extends JQueryStatic { + (selector: string, context?: any): IAugmentedJQuery; + (element: Element): IAugmentedJQuery; + (object: {}): IAugmentedJQuery; + (elementArray: Element[]): IAugmentedJQuery; + (object: JQuery): IAugmentedJQuery; + (func: Function): IAugmentedJQuery; + (array: any[]): IAugmentedJQuery; + (): IAugmentedJQuery; + } + + interface IAugmentedJQuery extends JQuery { + // TODO: events, how to define? + //$destroy + + find(selector: string): IAugmentedJQuery; + find(element: any): IAugmentedJQuery; + find(obj: JQuery): IAugmentedJQuery; + controller(): any; + controller(name: string): any; + injector(): any; + scope(): IScope; + isolateScope(): IScope; + + inheritedData(key: string, value: any): JQuery; + inheritedData(obj: { [key: string]: any; }): JQuery; + inheritedData(key?: string): any; + } + + /////////////////////////////////////////////////////////////////////////// + // AUTO module (angular.js) + /////////////////////////////////////////////////////////////////////////// + export module auto { + + /////////////////////////////////////////////////////////////////////// + // InjectorService + // see http://docs.angularjs.org/api/AUTO.$injector + /////////////////////////////////////////////////////////////////////// + interface IInjectorService { + annotate(fn: Function): string[]; + annotate(inlineAnnotatedFunction: any[]): string[]; + get(name: string, caller?: string): T; + has(name: string): boolean; + instantiate(typeConstructor: Function, locals?: any): T; + invoke(inlineAnnotatedFunction: any[]): any; + invoke(func: Function, context?: any, locals?: any): any; + } + + /////////////////////////////////////////////////////////////////////// + // ProvideService + // see http://docs.angularjs.org/api/AUTO.$provide + /////////////////////////////////////////////////////////////////////// + interface IProvideService { + // Documentation says it returns the registered instance, but actual + // implementation does not return anything. + // constant(name: string, value: any): any; + /** + * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator. + * + * @param name The name of the constant. + * @param value The constant value. + */ + constant(name: string, value: any): void; + + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. + * + * @param name The name of the service to decorate. + * @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: + * + * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. + */ + decorator(name: string, decorator: Function): void; + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. + * + * @param name The name of the service to decorate. + * @param inlineAnnotatedFunction This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: + * + * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. + */ + decorator(name: string, inlineAnnotatedFunction: any[]): void; + factory(name: string, serviceFactoryFunction: Function): IServiceProvider; + factory(name: string, inlineAnnotatedFunction: any[]): IServiceProvider; + provider(name: string, provider: IServiceProvider): IServiceProvider; + provider(name: string, serviceProviderConstructor: Function): IServiceProvider; + service(name: string, constructor: Function): IServiceProvider; + service(name: string, inlineAnnotatedFunction: any[]): IServiceProvider; + value(name: string, value: any): IServiceProvider; + } + + } +} diff --git a/angularjs/legacy/angular-animate-1.3.d.ts b/angularjs/legacy/angular-animate-1.3.d.ts new file mode 100644 index 0000000000..1f0184abd3 --- /dev/null +++ b/angularjs/legacy/angular-animate-1.3.d.ts @@ -0,0 +1,261 @@ +// Type definitions for Angular JS 1.3 (ngAnimate module) +// Project: http://angularjs.org +// Definitions by: Michel Salib , Adi Dahiya , Raphael Schweizer , Cody Schaaf +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "angular-animate" { + var _: string; + export = _; +} + +/** + * ngAnimate module (angular-animate.js) + */ +declare module angular.animate { + interface IAnimateFactory extends Function { + enter?: (element: ng.IAugmentedJQuery, doneFn: Function) => IAnimateCssRunner|void; + leave?: (element: ng.IAugmentedJQuery, doneFn: Function) => IAnimateCssRunner|void; + addClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void; + removeClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void; + setClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void; + } + + /** + * AnimateService + * see http://docs.angularjs.org/api/ngAnimate/service/$animate + */ + interface IAnimateService { + /** + * Globally enables / disables animations. + * + * @param element If provided then the element will be used to represent the enable/disable operation. + * @param value If provided then set the animation on or off. + * @returns current animation state + */ + enabled(element?: JQuery, value?: boolean): boolean; + + /** + * Performs an inline animation on the element. + * + * @param element the element that will be the focus of the animation + * @param from a collection of CSS styles that will be applied to the element at the start of the animation + * @param to a collection of CSS styles that the element will animate towards + * @param className an optional CSS class that will be added to the element for the duration of the animation (the default class is 'ng-inline-animate') + * @param options an optional collection of styles that will be picked up by the CSS transition/animation + * @returns the animation callback promise + */ + animate(element: JQuery, from: any, to: any, className?: string, options?: IAnimationOptions): IPromise; + + /** + * Appends the element to the parentElement element that resides in the document and then runs the enter animation. + * + * @param element the element that will be the focus of the enter animation + * @param parentElement the parent element of the element that will be the focus of the enter animation + * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation + * @param options an optional collection of styles that will be picked up by the CSS transition/animation + * @returns the animation callback promise + */ + enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, options?: IAnimationOptions): IPromise; + + /** + * Runs the leave animation operation and, upon completion, removes the element from the DOM. + * + * @param element the element that will be the focus of the leave animation + * @param options an optional collection of styles that will be picked up by the CSS transition/animation + * @returns the animation callback promise + */ + leave(element: JQuery, options?: IAnimationOptions): IPromise; + + /** + * Fires the move DOM operation. Just before the animation starts, the animate service will either append + * it into the parentElement container or add the element directly after the afterElement element if present. + * Then the move animation will be run. + * + * @param element the element that will be the focus of the move animation + * @param parentElement the parent element of the element that will be the focus of the move animation + * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation + * @returns the animation callback promise + */ + move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): IPromise; + + /** + * Triggers a custom animation event based off the className variable and then attaches the className + * value to the element as a CSS class. + * + * @param element the element that will be animated + * @param className the CSS class that will be added to the element and then animated + * @param options an optional collection of styles that will be picked up by the CSS transition/animation + * @returns the animation callback promise + */ + addClass(element: JQuery, className: string, options?: IAnimationOptions): IPromise; + + /** + * Triggers a custom animation event based off the className variable and then removes the CSS class + * provided by the className value from the element. + * + * @param element the element that will be animated + * @param className the CSS class that will be animated and then removed from the element + * @param options an optional collection of styles that will be picked up by the CSS transition/animation + * @returns the animation callback promise + */ + removeClass(element: JQuery, className: string, options?: IAnimationOptions): IPromise; + + /** + * Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback + * will be fired (if provided). + * + * @param element the element which will have its CSS classes changed removed from it + * @param add the CSS classes which will be added to the element + * @param remove the CSS class which will be removed from the element CSS classes have been set on the element + * @param options an optional collection of styles that will be picked up by the CSS transition/animation + * @returns the animation callback promise + */ + setClass(element: JQuery, add: string, remove: string, options?: IAnimationOptions): IPromise; + + /** + * Cancels the provided animation. + */ + cancel(animationPromise: IPromise): void; + } + + /** + * AnimateProvider + * see http://docs.angularjs.org/api/ngAnimate/provider/$animateProvider + */ + interface IAnimateProvider { + /** + * Registers a new injectable animation factory function. + * + * @param name The name of the animation. + * @param factory The factory function that will be executed to return the animation object. + */ + register(name: string, factory: () => IAnimateCallbackObject): void; + + /** + * Gets and/or sets the CSS class expression that is checked when performing an animation. + * + * @param expression The className expression which will be checked against all animations. + * @returns The current CSS className expression value. If null then there is no expression value. + */ + classNameFilter(expression?: RegExp): RegExp; + } + + /** + * Angular Animation Options + * see https://docs.angularjs.org/api/ngAnimate/#applying-directive-specific-styles-to-an-animation + */ + interface IAnimationOptions { + /** + * The ending CSS styles (a key/value object) that will be applied across the animation via a CSS transition. + */ + to?: Object; + + /** + * The starting CSS styles (a key/value object) that will be applied at the start of the animation. + */ + from?: Object; + + /** + * The DOM event (e.g. enter, leave, move). When used, a generated CSS class of ng-EVENT and + * ng-EVENT-active will be applied to the element during the animation. Multiple events can be provided when + * spaces are used as a separator. (Note that this will not perform any DOM operation.) + */ + event?: string; + + /** + * The CSS easing value that will be applied to the transition or keyframe animation (or both). + */ + easing?: string; + + /** + * The raw CSS transition style that will be used (e.g. 1s linear all). + */ + transition?: string; + + /** + * The raw CSS keyframe animation style that will be used (e.g. 1s my_animation linear). + */ + keyframe?: string; + + /** + * A space separated list of CSS classes that will be added to the element and spread across the animation. + */ + addClass?: string; + + /** + * A space separated list of CSS classes that will be removed from the element and spread across + * the animation. + */ + removeClass?: string; + + /** + * A number value representing the total duration of the transition and/or keyframe (note that a value + * of 1 is 1000ms). If a value of 0 is provided then the animation will be skipped entirely. + */ + duration?: number; + + /** + * A number value representing the total delay of the transition and/or keyframe (note that a value of + * 1 is 1000ms). If a value of true is used then whatever delay value is detected from the CSS classes will be + * mirrored on the elements styles (e.g. by setting delay true then the style value of the element will be + * transition-delay: DETECTED_VALUE). Using true is useful when you want the CSS classes and inline styles to + * all share the same CSS delay value. + */ + delay?: number; + + /** + * A numeric time value representing the delay between successively animated elements (Click here to + * learn how CSS-based staggering works in ngAnimate.) + */ + stagger?: number; + + /** + * The numeric index representing the stagger item (e.g. a value of 5 is equal to the sixth item + * in the stagger; therefore when a stagger option value of 0.1 is used then there will be a stagger delay of 600ms) + * applyClassesEarly - Whether or not the classes being added or removed will be used when detecting the animation. + * This is set by $animate when enter/leave/move animations are fired to ensure that the CSS classes are resolved in time. + * (Note that this will prevent any transitions from occuring on the classes being added and removed.) + */ + staggerIndex?: number; + } + + interface IAnimateCssRunner { + /** + * Starts the animation + * + * @returns The animation runner with a done function for supplying a callback. + */ + start(): IAnimateCssRunnerStart; + + /** + * Ends (aborts) the animation + */ + end(): void; + } + + interface IAnimateCssRunnerStart extends IPromise { + /** + * Allows you to add done callbacks to the running animation + * + * @param callbackFn: the callback function to be run + */ + done(callbackFn: (animationFinished: boolean) => void): void; + } + + /** + * AnimateCssService + * see http://docs.angularjs.org/api/ngAnimate/service/$animateCss + */ + interface IAnimateCssService { + (element: JQuery, animateCssOptions: IAnimationOptions): IAnimateCssRunner; + } + +} + +declare module angular { + interface IModule { + animate(cssSelector: string, animateFactory: angular.animate.IAnimateFactory): IModule; + } +} diff --git a/angularjs/legacy/angular-resource-1.3.d.ts b/angularjs/legacy/angular-resource-1.3.d.ts new file mode 100644 index 0000000000..0d105e1cc8 --- /dev/null +++ b/angularjs/legacy/angular-resource-1.3.d.ts @@ -0,0 +1,185 @@ +// Type definitions for Angular JS 1.3 (ngResource module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar , Michael Jess +// Definitions: https://github.com/daptiv/DefinitelyTyped + +/// + +declare module 'angular-resource' { + var _: string; + export = _; +} + +/////////////////////////////////////////////////////////////////////////////// +// ngResource module (angular-resource.js) +/////////////////////////////////////////////////////////////////////////////// +declare module angular.resource { + + /** + * Currently supported options for the $resource factory options argument. + */ + interface IResourceOptions { + /** + * If true then the trailing slashes from any calculated URL will be stripped (defaults to true) + */ + stripTrailingSlashes?: boolean; + } + + + /////////////////////////////////////////////////////////////////////////// + // ResourceService + // see http://docs.angularjs.org/api/ngResource.$resource + // Most part of the following definitions were achieved by analyzing the + // actual implementation, since the documentation doesn't seem to cover + // that deeply. + /////////////////////////////////////////////////////////////////////////// + interface IResourceService { + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actions?: any, options?: IResourceOptions): IResourceClass>; + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actions?: any, options?: IResourceOptions): U; + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actions?: any, options?: IResourceOptions): IResourceClass; + } + + // Just a reference to facilitate describing new actions + interface IActionDescriptor { + method: string; + params?: any; + url?: string; + isArray?: boolean; + transformRequest?: angular.IHttpRequestTransformer | angular.IHttpRequestTransformer[]; + transformResponse?: angular.IHttpResponseTransformer | angular.IHttpResponseTransformer[]; + headers?: any; + cache?: boolean | angular.ICacheObject; + timeout?: number | angular.IPromise; + withCredentials?: boolean; + responseType?: string; + interceptor?: any; + } + + // Baseclass for everyresource with default actions. + // If you define your new actions for the resource, you will need + // to extend this interface and typecast the ResourceClass to it. + // + // In case of passing the first argument as anything but a function, + // it's gonna be considered data if the action method is POST, PUT or + // 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 + // + // Only those methods with an HTTP body do have 'data' as first parameter: + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463 + // More specifically, those methods are POST, PUT and PATCH: + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432 + // + // Also, static calls always return the IResource (or IResourceArray) retrieved + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549 + interface IResourceClass { + new(dataOrParams? : any) : T; + get(): T; + get(params: Object): T; + get(success: Function, error?: Function): T; + get(params: Object, success: Function, error?: Function): T; + get(params: Object, data: Object, success?: Function, error?: Function): T; + + query(): IResourceArray; + query(params: Object): IResourceArray; + query(success: Function, error?: Function): IResourceArray; + query(params: Object, success: Function, error?: Function): IResourceArray; + query(params: Object, data: Object, success?: Function, error?: Function): IResourceArray; + + save(): T; + save(data: Object): T; + save(success: Function, error?: Function): T; + save(data: Object, success: Function, error?: Function): T; + save(params: Object, data: Object, success?: Function, error?: Function): T; + + remove(): T; + remove(params: Object): T; + remove(success: Function, error?: Function): T; + remove(params: Object, success: Function, error?: Function): T; + remove(params: Object, data: Object, success?: Function, error?: Function): T; + + delete(): T; + delete(params: Object): T; + delete(success: Function, error?: Function): T; + delete(params: Object, success: Function, error?: Function): T; + delete(params: Object, data: Object, success?: Function, error?: Function): T; + } + + // Instance calls always return the the promise of the request which retrieved the object + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546 + interface IResource { + $get(): angular.IPromise; + $get(params?: Object, success?: Function, error?: Function): angular.IPromise; + $get(success: Function, error?: Function): angular.IPromise; + + $query(): angular.IPromise>; + $query(params?: Object, success?: Function, error?: Function): angular.IPromise>; + $query(success: Function, error?: Function): angular.IPromise>; + + $save(): angular.IPromise; + $save(params?: Object, success?: Function, error?: Function): angular.IPromise; + $save(success: Function, error?: Function): angular.IPromise; + + $remove(): angular.IPromise; + $remove(params?: Object, success?: Function, error?: Function): angular.IPromise; + $remove(success: Function, error?: Function): angular.IPromise; + + $delete(): angular.IPromise; + $delete(params?: Object, success?: Function, error?: Function): angular.IPromise; + $delete(success: Function, error?: Function): angular.IPromise; + + /** the promise of the original server interaction that created this instance. **/ + $promise : angular.IPromise; + $resolved : boolean; + toJSON: () => { + [index: string]: any; + } + } + + /** + * Really just a regular Array object with $promise and $resolve attached to it + */ + interface IResourceArray extends Array> { + /** the promise of the original server interaction that created this collection. **/ + $promise : angular.IPromise>; + $resolved : boolean; + } + + /** when creating a resource factory via IModule.factory */ + interface IResourceServiceFactoryFunction { + ($resource: angular.resource.IResourceService): IResourceClass; + >($resource: angular.resource.IResourceService): U; + } + + // IResourceServiceProvider used to configure global settings + interface IResourceServiceProvider extends angular.IServiceProvider { + + defaults: IResourceOptions; + } + +} + +/** extensions to base ng based on using angular-resource */ +declare module angular { + + interface IModule { + /** creating a resource service factory */ + factory(name: string, resourceServiceFactoryFunction: angular.resource.IResourceServiceFactoryFunction): IModule; + } +} + +interface Array +{ + /** the promise of the original server interaction that created this collection. **/ + $promise : angular.IPromise>; + $resolved : boolean; +}