re base code
[sdc.git] / catalog-ui / src / typings / angularjs / angular.d.ts
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 // Type definitions for Angular JS 1.3+
21 // Project: http://angularjs.org
22 // Definitions by: Diego Vilar <http://github.com/diegovilar>
23 // Definitions: https://github.com/borisyankov/DefinitelyTyped
24
25
26 /// <reference path="../jquery/jquery.d.ts" />
27
28 declare var angular: angular.IAngularStatic;
29
30 // Support for painless dependency injection
31 interface Function {
32     $inject?: string[];
33 }
34
35 // Collapse angular into ng
36 import ng = angular;
37 // Support AMD require
38 declare module 'angular' {
39     export = angular;
40 }
41
42 ///////////////////////////////////////////////////////////////////////////////
43 // ng module (angular.js)
44 ///////////////////////////////////////////////////////////////////////////////
45 declare module angular {
46
47     // not directly implemented, but ensures that constructed class implements $get
48     interface IServiceProviderClass {
49         new (...args: any[]): IServiceProvider;
50     }
51
52     interface IServiceProviderFactory {
53         (...args: any[]): IServiceProvider;
54     }
55
56     // All service providers extend this interface
57     interface IServiceProvider {
58         $get: any;
59     }
60
61     interface IAngularBootstrapConfig {
62         strictDi?: boolean;
63     }
64
65     ///////////////////////////////////////////////////////////////////////////
66     // AngularStatic
67     // see http://docs.angularjs.org/api
68     ///////////////////////////////////////////////////////////////////////////
69     interface IAngularStatic {
70         bind(context: any, fn: Function, ...args: any[]): Function;
71
72         /**
73          * Use this function to manually start up angular application.
74          *
75          * @param element DOM element which is the root of angular application.
76          * @param modules An array of modules to load into the application.
77          *     Each item in the array should be the name of a predefined module or a (DI annotated)
78          *     function that will be invoked by the injector as a run block.
79          * @param config an object for defining configuration options for the application. The following keys are supported:
80          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
81          */
82         bootstrap(element: string, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
83         /**
84          * Use this function to manually start up angular application.
85          *
86          * @param element DOM element which is the root of angular application.
87          * @param modules An array of modules to load into the application.
88          *     Each item in the array should be the name of a predefined module or a (DI annotated)
89          *     function that will be invoked by the injector as a run block.
90          * @param config an object for defining configuration options for the application. The following keys are supported:
91          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
92          */
93         bootstrap(element: string, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
94         /**
95          * Use this function to manually start up angular application.
96          *
97          * @param element DOM element which is the root of angular application.
98          * @param modules An array of modules to load into the application.
99          *     Each item in the array should be the name of a predefined module or a (DI annotated)
100          *     function that will be invoked by the injector as a run block.
101          * @param config an object for defining configuration options for the application. The following keys are supported:
102          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
103          */
104         bootstrap(element: string, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
105         /**
106          * Use this function to manually start up angular application.
107          *
108          * @param element DOM element which is the root of angular application.
109          * @param modules An array of modules to load into the application.
110          *     Each item in the array should be the name of a predefined module or a (DI annotated)
111          *     function that will be invoked by the injector as a run block.
112          * @param config an object for defining configuration options for the application. The following keys are supported:
113          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
114          */
115         bootstrap(element: JQuery, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
116         /**
117          * Use this function to manually start up angular application.
118          *
119          * @param element DOM element which is the root of angular application.
120          * @param modules An array of modules to load into the application.
121          *     Each item in the array should be the name of a predefined module or a (DI annotated)
122          *     function that will be invoked by the injector as a run block.
123          * @param config an object for defining configuration options for the application. The following keys are supported:
124          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
125          */
126         bootstrap(element: JQuery, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
127         /**
128          * Use this function to manually start up angular application.
129          *
130          * @param element DOM element which is the root of angular application.
131          * @param modules An array of modules to load into the application.
132          *     Each item in the array should be the name of a predefined module or a (DI annotated)
133          *     function that will be invoked by the injector as a run block.
134          * @param config an object for defining configuration options for the application. The following keys are supported:
135          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
136          */
137         bootstrap(element: JQuery, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
138         /**
139          * Use this function to manually start up angular application.
140          *
141          * @param element DOM element which is the root of angular application.
142          * @param modules An array of modules to load into the application.
143          *     Each item in the array should be the name of a predefined module or a (DI annotated)
144          *     function that will be invoked by the injector as a run block.
145          * @param config an object for defining configuration options for the application. The following keys are supported:
146          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
147          */
148         bootstrap(element: Element, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
149         /**
150          * Use this function to manually start up angular application.
151          *
152          * @param element DOM element which is the root of angular application.
153          * @param modules An array of modules to load into the application.
154          *     Each item in the array should be the name of a predefined module or a (DI annotated)
155          *     function that will be invoked by the injector as a run block.
156          * @param config an object for defining configuration options for the application. The following keys are supported:
157          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
158          */
159         bootstrap(element: Element, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
160         /**
161          * Use this function to manually start up angular application.
162          *
163          * @param element DOM element which is the root of angular application.
164          * @param modules An array of modules to load into the application.
165          *     Each item in the array should be the name of a predefined module or a (DI annotated)
166          *     function that will be invoked by the injector as a run block.
167          * @param config an object for defining configuration options for the application. The following keys are supported:
168          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
169          */
170         bootstrap(element: Element, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
171         /**
172          * Use this function to manually start up angular application.
173          *
174          * @param element DOM element which is the root of angular application.
175          * @param modules An array of modules to load into the application.
176          *     Each item in the array should be the name of a predefined module or a (DI annotated)
177          *     function that will be invoked by the injector as a run block.
178          * @param config an object for defining configuration options for the application. The following keys are supported:
179          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
180          */
181         bootstrap(element: Document, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
182         /**
183          * Use this function to manually start up angular application.
184          *
185          * @param element DOM element which is the root of angular application.
186          * @param modules An array of modules to load into the application.
187          *     Each item in the array should be the name of a predefined module or a (DI annotated)
188          *     function that will be invoked by the injector as a run block.
189          * @param config an object for defining configuration options for the application. The following keys are supported:
190          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
191          */
192         bootstrap(element: Document, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
193         /**
194          * Use this function to manually start up angular application.
195          *
196          * @param element DOM element which is the root of angular application.
197          * @param modules An array of modules to load into the application.
198          *     Each item in the array should be the name of a predefined module or a (DI annotated)
199          *     function that will be invoked by the injector as a run block.
200          * @param config an object for defining configuration options for the application. The following keys are supported:
201          *     - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
202          */
203         bootstrap(element: Document, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
204
205         /**
206          * Creates a deep copy of source, which should be an object or an array.
207          *
208          * - If no destination is supplied, a copy of the object or array is created.
209          * - 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.
210          * - If source is not an object or array (inc. null and undefined), source is returned.
211          * - If source is identical to 'destination' an exception will be thrown.
212          *
213          * @param source The source that will be used to make a copy. Can be any type, including primitives, null, and undefined.
214          * @param destination Destination into which the source is copied. If provided, must be of the same type as source.
215          */
216         copy<T>(source: T, destination?: T): T;
217
218         /**
219          * Wraps a raw DOM element or HTML string as a jQuery element.
220          *
221          * 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."
222          */
223         element: IAugmentedJQueryStatic;
224         equals(value1: any, value2: any): boolean;
225         extend(destination: any, ...sources: any[]): any;
226
227         /**
228          * 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.
229          *
230          * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
231          *
232          * @param obj Object to iterate over.
233          * @param iterator Iterator function.
234          * @param context Object to become context (this) for the iterator function.
235          */
236         forEach<T>(obj: T[], iterator: (value: T, key: number) => any, context?: any): any;
237         /**
238          * 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.
239          *
240          * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
241          *
242          * @param obj Object to iterate over.
243          * @param iterator Iterator function.
244          * @param context Object to become context (this) for the iterator function.
245          */
246         forEach<T>(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any;
247         /**
248          * 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.
249          *
250          * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
251          *
252          * @param obj Object to iterate over.
253          * @param iterator Iterator function.
254          * @param context Object to become context (this) for the iterator function.
255          */
256         forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any;
257
258         fromJson(json: string): any;
259         identity(arg?: any): any;
260         injector(modules?: any[]): auto.IInjectorService;
261         isArray(value: any): boolean;
262         isDate(value: any): boolean;
263         isDefined(value: any): boolean;
264         isElement(value: any): boolean;
265         isFunction(value: any): boolean;
266         isNumber(value: any): boolean;
267         isObject(value: any): boolean;
268         isString(value: any): boolean;
269         isUndefined(value: any): boolean;
270         lowercase(str: string): string;
271
272         /**
273          * 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.
274          *
275          * 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.
276          *
277          * @param name The name of the module to create or retrieve.
278          * @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.
279          * @param configFn Optional configuration function for the module.
280          */
281         module(
282             name: string,
283             requires?: string[],
284             configFn?: Function): IModule;
285
286         noop(...args: any[]): void;
287         reloadWithDebugInfo(): void;
288         toJson(obj: any, pretty?: boolean): string;
289         uppercase(str: string): string;
290         version: {
291             full: string;
292             major: number;
293             minor: number;
294             dot: number;
295             codeName: string;
296         };
297     }
298
299     ///////////////////////////////////////////////////////////////////////////
300     // Module
301     // see http://docs.angularjs.org/api/angular.Module
302     ///////////////////////////////////////////////////////////////////////////
303     interface IModule {
304         animation(name: string, animationFactory: Function): IModule;
305         animation(name: string, inlineAnnotatedFunction: any[]): IModule;
306         animation(object: Object): IModule;
307         /**
308          * Use this method to register work which needs to be performed on module loading.
309          *
310          * @param configFn Execute this function on module load. Useful for service configuration.
311          */
312         config(configFn: Function): IModule;
313         /**
314          * Use this method to register work which needs to be performed on module loading.
315          *
316          * @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration.
317          */
318         config(inlineAnnotatedFunction: any[]): IModule;
319         /**
320          * 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.
321          *
322          * @param name The name of the constant.
323          * @param value The constant value.
324          */
325         constant(name: string, value: any): IModule;
326         constant(object: Object): IModule;
327         /**
328          * The $controller service is used by Angular to create new controllers.
329          *
330          * This provider allows controller registration via the register method.
331          *
332          * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
333          * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
334          */
335         controller(name: string, controllerConstructor: Function): IModule;
336         /**
337          * The $controller service is used by Angular to create new controllers.
338          *
339          * This provider allows controller registration via the register method.
340          *
341          * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
342          * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
343          */
344         controller(name: string, inlineAnnotatedConstructor: any[]): IModule;
345         controller(object: Object): IModule;
346         /**
347          * Register a new directive with the compiler.
348          *
349          * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind)
350          * @param directiveFactory An injectable directive factory function.
351          */
352         directive(name: string, directiveFactory: IDirectiveFactory): IModule;
353         /**
354          * Register a new directive with the compiler.
355          *
356          * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind)
357          * @param directiveFactory An injectable directive factory function.
358          */
359         directive(name: string, inlineAnnotatedFunction: any[]): IModule;
360         directive(object: Object): IModule;
361         /**
362          * 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.
363          *
364          * @param name The name of the instance.
365          * @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
366          */
367         factory(name: string, $getFn: Function): IModule;
368         /**
369          * 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.
370          *
371          * @param name The name of the instance.
372          * @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
373          */
374         factory(name: string, inlineAnnotatedFunction: any[]): IModule;
375         factory(object: Object): IModule;
376         filter(name: string, filterFactoryFunction: Function): IModule;
377         filter(name: string, inlineAnnotatedFunction: any[]): IModule;
378         filter(object: Object): IModule;
379         provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule;
380         provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule;
381         provider(name: string, inlineAnnotatedConstructor: any[]): IModule;
382         provider(name: string, providerObject: IServiceProvider): IModule;
383         provider(object: Object): IModule;
384         /**
385          * 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.
386          */
387         run(initializationFunction: Function): IModule;
388         /**
389          * 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.
390          */
391         run(inlineAnnotatedFunction: any[]): IModule;
392         service(name: string, serviceConstructor: Function): IModule;
393         service(name: string, inlineAnnotatedConstructor: any[]): IModule;
394         service(object: Object): IModule;
395         /**
396          * 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.
397
398            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.
399          *
400          * @param name The name of the instance.
401          * @param value The value.
402          */
403         value(name: string, value: any): IModule;
404         value(object: Object): IModule;
405
406         // Properties
407         name: string;
408         requires: string[];
409     }
410
411     ///////////////////////////////////////////////////////////////////////////
412     // Attributes
413     // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes
414     ///////////////////////////////////////////////////////////////////////////
415     interface IAttributes {
416         /**
417          * this is necessary to be able to access the scoped attributes. it's not very elegant
418          * because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way
419          * this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656
420          */
421         [name: string]: any;
422
423         /**
424          * Adds the CSS class value specified by the classVal parameter to the
425          * element. If animations are enabled then an animation will be triggered
426          * for the class addition.
427          */
428         $addClass(classVal: string): void;
429
430         /**
431          * Removes the CSS class value specified by the classVal parameter from the
432          * element. If animations are enabled then an animation will be triggered for
433          * the class removal.
434          */
435         $removeClass(classVal: string): void;
436
437         /**
438          * Set DOM element attribute value.
439          */
440         $set(key: string, value: any): void;
441
442         /**
443          * Observes an interpolated attribute.
444          * The observer function will be invoked once during the next $digest
445          * following compilation. The observer is then invoked whenever the
446          * interpolated value changes.
447          */
448         $observe(name: string, fn: (value?: any) => any): Function;
449
450         /**
451          * A map of DOM element attribute names to the normalized name. This is needed
452          * to do reverse lookup from normalized name back to actual name.
453          */
454         $attr: Object;
455     }
456
457     /**
458      * form.FormController - type in module ng
459      * see https://docs.angularjs.org/api/ng/type/form.FormController
460      */
461     interface IFormController {
462
463         /**
464          * 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
465          */
466         [name: string]: any;
467
468         $pristine: boolean;
469         $dirty: boolean;
470         $valid: boolean;
471         $invalid: boolean;
472         $submitted: boolean;
473         $error: any;
474         $addControl(control: INgModelController): void;
475         $removeControl(control: INgModelController): void;
476         $setValidity(validationErrorKey: string, isValid: boolean, control: INgModelController): void;
477         $setDirty(): void;
478         $setPristine(): void;
479         $commitViewValue(): void;
480         $rollbackViewValue(): void;
481         $setSubmitted(): void;
482         $setUntouched(): void;
483     }
484
485     ///////////////////////////////////////////////////////////////////////////
486     // NgModelController
487     // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController
488     ///////////////////////////////////////////////////////////////////////////
489     interface INgModelController {
490         $render(): void;
491         $setValidity(validationErrorKey: string, isValid: boolean): void;
492         // Documentation states viewValue and modelValue to be a string but other
493         // types do work and it's common to use them.
494         $setViewValue(value: any, trigger?: string): void;
495         $setPristine(): void;
496         $validate(): void;
497         $setTouched(): void;
498         $setUntouched(): void;
499         $rollbackViewValue(): void;
500         $commitViewValue(): void;
501         $isEmpty(value: any): boolean;
502
503         $viewValue: any;
504
505         $modelValue: any;
506
507         $parsers: IModelParser[];
508         $formatters: IModelFormatter[];
509         $viewChangeListeners: IModelViewChangeListener[];
510         $error: any;
511         $name: string;
512
513         $touched: boolean;
514         $untouched: boolean;
515
516         $validators: IModelValidators;
517         $asyncValidators: IAsyncModelValidators;
518
519         $pending: any;
520         $pristine: boolean;
521         $dirty: boolean;
522         $valid: boolean;
523         $invalid: boolean;
524     }
525
526     interface IModelValidators {
527         [index: string]: (...args: any[]) => boolean;
528     }
529
530     interface IAsyncModelValidators {
531         [index: string]: (...args: any[]) => IPromise<boolean>;
532     }
533
534     interface IModelParser {
535         (value: any): any;
536     }
537
538     interface IModelFormatter {
539         (value: any): any;
540     }
541
542     interface IModelViewChangeListener {
543         (): void;
544     }
545
546     /**
547      * $rootScope - $rootScopeProvider - service in module ng
548      * see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope
549      */
550     interface IRootScopeService {
551         [index: string]: any;
552
553         $apply(): any;
554         $apply(exp: string): any;
555         $apply(exp: (scope: IScope) => any): any;
556
557         $applyAsync(): any;
558         $applyAsync(exp: string): any;
559         $applyAsync(exp: (scope: IScope) => any): any;
560
561         $broadcast(name: string, ...args: any[]): IAngularEvent;
562         $destroy(): void;
563         $digest(): void;
564         $emit(name: string, ...args: any[]): IAngularEvent;
565
566         $eval(): any;
567         $eval(expression: string, locals?: Object): any;
568         $eval(expression: (scope: IScope) => any, locals?: Object): any;
569
570         $evalAsync(): void;
571         $evalAsync(expression: string): void;
572         $evalAsync(expression: (scope: IScope) => any): void;
573
574         // Defaults to false by the implementation checking strategy
575         $new(isolate?: boolean, parent?: IScope): IScope;
576
577         /**
578          * Listens on events of a given type. See $emit for discussion of event life cycle.
579          *
580          * The event listener function format is: function(event, args...).
581          *
582          * @param name Event name to listen on.
583          * @param listener Function to call when the event is emitted.
584          */
585         $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function;
586
587         $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function;
588         $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function;
589         $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function;
590         $watch(watchExpression: (scope: IScope) => any, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function;
591
592         $watchCollection(watchExpression: string, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
593         $watchCollection(watchExpression: (scope: IScope) => any, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
594
595         $watchGroup(watchExpressions: any[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
596         $watchGroup(watchExpressions: { (scope: IScope): any }[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
597
598         $parent: IScope;
599         $root: IRootScopeService;
600         $id: number;
601
602         // Hidden members
603         $$isolateBindings: any;
604         $$phase: any;
605     }
606
607     interface IScope extends IRootScopeService { }
608
609     /**
610      * $scope for ngRepeat directive.
611      * see https://docs.angularjs.org/api/ng/directive/ngRepeat
612      */
613     interface IRepeatScope extends IScope {
614
615         /**
616          * iterator offset of the repeated element (0..length-1).
617          */
618         $index: number;
619
620         /**
621          * true if the repeated element is first in the iterator.
622          */
623         $first: boolean;
624
625         /**
626          * true if the repeated element is between the first and last in the iterator.
627          */
628         $middle: boolean;
629
630         /**
631          * true if the repeated element is last in the iterator.
632          */
633         $last: boolean;
634
635         /**
636          * true if the iterator position $index is even (otherwise false).
637          */
638         $even: boolean;
639
640         /**
641          * true if the iterator position $index is odd (otherwise false).
642          */
643         $odd: boolean;
644
645         }
646
647     interface IAngularEvent {
648         /**
649          * the scope on which the event was $emit-ed or $broadcast-ed.
650          */
651         targetScope: IScope;
652         /**
653          * the scope that is currently handling the event. Once the event propagates through the scope hierarchy, this property is set to null.
654          */
655         currentScope: IScope;
656         /**
657          * name of the event.
658          */
659         name: string;
660         /**
661          * calling stopPropagation function will cancel further event propagation (available only for events that were $emit-ed).
662          */
663         stopPropagation?: Function;
664         /**
665          * calling preventDefault sets defaultPrevented flag to true.
666          */
667         preventDefault: Function;
668         /**
669          * true if preventDefault was called.
670          */
671         defaultPrevented: boolean;
672     }
673
674     ///////////////////////////////////////////////////////////////////////////
675     // WindowService
676     // see http://docs.angularjs.org/api/ng.$window
677     ///////////////////////////////////////////////////////////////////////////
678     interface IWindowService extends Window {
679         [key: string]: any;
680     }
681
682     ///////////////////////////////////////////////////////////////////////////
683     // BrowserService
684     // TODO undocumented, so we need to get it from the source code
685     ///////////////////////////////////////////////////////////////////////////
686     interface IBrowserService {
687         defer: angular.ITimeoutService;
688         [key: string]: any;
689     }
690
691     ///////////////////////////////////////////////////////////////////////////
692     // TimeoutService
693     // see http://docs.angularjs.org/api/ng.$timeout
694     ///////////////////////////////////////////////////////////////////////////
695     interface ITimeoutService {
696         (func: Function, delay?: number, invokeApply?: boolean): IPromise<any>;
697         cancel(promise: IPromise<any>): boolean;
698     }
699
700     ///////////////////////////////////////////////////////////////////////////
701     // IntervalService
702     // see http://docs.angularjs.org/api/ng.$interval
703     ///////////////////////////////////////////////////////////////////////////
704     interface IIntervalService {
705         (func: Function, delay: number, count?: number, invokeApply?: boolean): IPromise<any>;
706         cancel(promise: IPromise<any>): boolean;
707     }
708
709     ///////////////////////////////////////////////////////////////////////////
710     // AngularProvider
711     // see http://docs.angularjs.org/api/ng/provider/$animateProvider
712     ///////////////////////////////////////////////////////////////////////////
713     interface IAnimateProvider {
714         /**
715          * Registers a new injectable animation factory function.
716          *
717          * @param name The name of the animation.
718          * @param factory The factory function that will be executed to return the animation object.
719          */
720         register(name: string, factory: () => IAnimateCallbackObject): void;
721
722         /**
723          * Gets and/or sets the CSS class expression that is checked when performing an animation.
724          *
725          * @param expression The className expression which will be checked against all animations.
726          * @returns The current CSS className expression value. If null then there is no expression value.
727          */
728         classNameFilter(expression?: RegExp): RegExp;
729     }
730
731     /**
732      * The animation object which contains callback functions for each event that is expected to be animated.
733      */
734     interface IAnimateCallbackObject {
735         eventFn(element: Node, doneFn: () => void): Function;
736     }
737
738     ///////////////////////////////////////////////////////////////////////////
739     // FilterService
740     // see http://docs.angularjs.org/api/ng.$filter
741     // see http://docs.angularjs.org/api/ng.$filterProvider
742     ///////////////////////////////////////////////////////////////////////////
743     interface IFilterService {
744         (name: string): Function;
745     }
746
747     interface IFilterProvider extends IServiceProvider {
748         register(name: string, filterFactory: Function): IServiceProvider;
749     }
750
751     ///////////////////////////////////////////////////////////////////////////
752     // LocaleService
753     // see http://docs.angularjs.org/api/ng.$locale
754     ///////////////////////////////////////////////////////////////////////////
755     interface ILocaleService {
756         id: string;
757
758         // These are not documented
759         // Check angular's i18n files for exemples
760         NUMBER_FORMATS: ILocaleNumberFormatDescriptor;
761         DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor;
762         pluralCat: (num: any) => string;
763     }
764
765     interface ILocaleNumberFormatDescriptor {
766         DECIMAL_SEP: string;
767         GROUP_SEP: string;
768         PATTERNS: ILocaleNumberPatternDescriptor[];
769         CURRENCY_SYM: string;
770     }
771
772     interface ILocaleNumberPatternDescriptor {
773         minInt: number;
774         minFrac: number;
775         maxFrac: number;
776         posPre: string;
777         posSuf: string;
778         negPre: string;
779         negSuf: string;
780         gSize: number;
781         lgSize: number;
782     }
783
784     interface ILocaleDateTimeFormatDescriptor {
785         MONTH: string[];
786         SHORTMONTH: string[];
787         DAY: string[];
788         SHORTDAY: string[];
789         AMPMS: string[];
790         medium: string;
791         short: string;
792         fullDate: string;
793         longDate: string;
794         mediumDate: string;
795         shortDate: string;
796         mediumTime: string;
797         shortTime: string;
798     }
799
800     ///////////////////////////////////////////////////////////////////////////
801     // LogService
802     // see http://docs.angularjs.org/api/ng.$log
803     // see http://docs.angularjs.org/api/ng.$logProvider
804     ///////////////////////////////////////////////////////////////////////////
805     interface ILogService {
806         debug: ILogCall;
807         error: ILogCall;
808         info: ILogCall;
809         log: ILogCall;
810         warn: ILogCall;
811     }
812
813     interface ILogProvider {
814         debugEnabled(): boolean;
815         debugEnabled(enabled: boolean): ILogProvider;
816     }
817
818     // We define this as separate interface so we can reopen it later for
819     // the ngMock module.
820     interface ILogCall {
821         (...args: any[]): void;
822     }
823
824     ///////////////////////////////////////////////////////////////////////////
825     // ParseService
826     // see http://docs.angularjs.org/api/ng.$parse
827     // see http://docs.angularjs.org/api/ng.$parseProvider
828     ///////////////////////////////////////////////////////////////////////////
829     interface IParseService {
830         (expression: string): ICompiledExpression;
831     }
832
833     interface IParseProvider {
834         logPromiseWarnings(): boolean;
835         logPromiseWarnings(value: boolean): IParseProvider;
836
837         unwrapPromises(): boolean;
838         unwrapPromises(value: boolean): IParseProvider;
839     }
840
841     interface ICompiledExpression {
842         (context: any, locals?: any): any;
843
844         // If value is not provided, undefined is gonna be used since the implementation
845         // does not check the parameter. Let's force a value for consistency. If consumer
846         // whants to undefine it, pass the undefined value explicitly.
847         assign(context: any, value: any): any;
848     }
849
850     /**
851      * $location - $locationProvider - service in module ng
852      * see https://docs.angularjs.org/api/ng/service/$location
853      */
854     interface ILocationService {
855         absUrl(): string;
856         hash(): string;
857         hash(newHash: string): ILocationService;
858         host(): string;
859
860         /**
861          * Return path of current url
862          */
863         path(): string;
864
865         /**
866          * Change path when called with parameter and return $location.
867          * Note: Path should always begin with forward slash (/), this method will add the forward slash if it is missing.
868          *
869          * @param path New path
870          */
871         path(path: string): ILocationService;
872
873         port(): number;
874         protocol(): string;
875         replace(): ILocationService;
876
877         /**
878          * Return search part (as object) of current url
879          */
880         search(): any;
881
882         /**
883          * Change search part when called with parameter and return $location.
884          *
885          * @param search When called with a single argument the method acts as a setter, setting the search component of $location to the specified value.
886          *
887          * If the argument is a hash object containing an array of values, these values will be encoded as duplicate search parameters in the url.
888          */
889         search(search: any): ILocationService;
890
891         /**
892          * Change search part when called with parameter and return $location.
893          *
894          * @param search New search params
895          * @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.
896          */
897         search(search: string, paramValue: string|number|string[]|boolean): ILocationService;
898
899         state(): any;
900         state(state: any): ILocationService;
901         url(): string;
902         url(url: string): ILocationService;
903     }
904
905     interface ILocationProvider extends IServiceProvider {
906         hashPrefix(): string;
907         hashPrefix(prefix: string): ILocationProvider;
908         html5Mode(): boolean;
909
910         // Documentation states that parameter is string, but
911         // implementation tests it as boolean, which makes more sense
912         // since this is a toggler
913         html5Mode(active: boolean): ILocationProvider;
914         html5Mode(mode: { enabled?: boolean; requireBase?: boolean; rewriteLinks?: boolean; }): ILocationProvider;
915     }
916
917     ///////////////////////////////////////////////////////////////////////////
918     // DocumentService
919     // see http://docs.angularjs.org/api/ng.$document
920     ///////////////////////////////////////////////////////////////////////////
921     interface IDocumentService extends IAugmentedJQuery {}
922
923     ///////////////////////////////////////////////////////////////////////////
924     // ExceptionHandlerService
925     // see http://docs.angularjs.org/api/ng.$exceptionHandler
926     ///////////////////////////////////////////////////////////////////////////
927     interface IExceptionHandlerService {
928         (exception: Error, cause?: string): void;
929     }
930
931     ///////////////////////////////////////////////////////////////////////////
932     // RootElementService
933     // see http://docs.angularjs.org/api/ng.$rootElement
934     ///////////////////////////////////////////////////////////////////////////
935     interface IRootElementService extends JQuery {}
936
937     interface IQResolveReject<T> {
938         (): void;
939         (value: T): void;
940     }
941     /**
942      * $q - service in module ng
943      * A promise/deferred implementation inspired by Kris Kowal's Q.
944      * See http://docs.angularjs.org/api/ng/service/$q
945      */
946     interface IQService {
947         new (resolver: (resolve: IQResolveReject<any>) => any): IPromise<any>;
948         new (resolver: (resolve: IQResolveReject<any>, reject: IQResolveReject<any>) => any): IPromise<any>;
949         new <T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>;
950
951         /**
952          * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
953          *
954          * 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.
955          *
956          * @param promises An array of promises.
957          */
958         all(promises: IPromise<any>[]): IPromise<any[]>;
959         /**
960          * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
961          *
962          * 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.
963          *
964          * @param promises A hash of promises.
965          */
966         all(promises: { [id: string]: IPromise<any>; }): IPromise<{ [id: string]: any; }>;
967         /**
968          * Creates a Deferred object which represents a task which will finish in the future.
969          */
970         defer<T>(): IDeferred<T>;
971         /**
972          * 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.
973          *
974          * 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.
975          *
976          * @param reason Constant, message, exception or an object representing the rejection reason.
977          */
978         reject(reason?: any): IPromise<any>;
979         /**
980          * 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.
981          *
982          * @param value Value or a promise
983          */
984         when<T>(value: IPromise<T>|T): IPromise<T>;
985         /**
986          * 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.
987          *
988          * @param value Value or a promise
989          */
990         when(): IPromise<void>;
991     }
992
993     interface IPromise<T> {
994         /**
995          * 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.
996          *
997          * 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.
998          */
999         then<TResult>(successCallback: (promiseValue: T) => IHttpPromise<TResult>|IPromise<TResult>|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>;
1000
1001         /**
1002          * Shorthand for promise.then(null, errorCallback)
1003          */
1004         catch<TResult>(onRejected: (reason: any) => IHttpPromise<TResult>|IPromise<TResult>|TResult): IPromise<TResult>;
1005
1006         /**
1007          * 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.
1008          *
1009          * 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.
1010          */
1011         finally<TResult>(finallyCallback: () => any): IPromise<TResult>;
1012     }
1013
1014     interface IDeferred<T> {
1015         resolve(value?: T): void;
1016         reject(reason?: any): void;
1017         notify(state?: any): void;
1018         promise: IPromise<T>;
1019     }
1020
1021     ///////////////////////////////////////////////////////////////////////////
1022     // AnchorScrollService
1023     // see http://docs.angularjs.org/api/ng.$anchorScroll
1024     ///////////////////////////////////////////////////////////////////////////
1025     interface IAnchorScrollService {
1026         (): void;
1027         yOffset: any;
1028     }
1029
1030     interface IAnchorScrollProvider extends IServiceProvider {
1031         disableAutoScrolling(): void;
1032     }
1033
1034     ///////////////////////////////////////////////////////////////////////////
1035     // CacheFactoryService
1036     // see http://docs.angularjs.org/api/ng.$cacheFactory
1037     ///////////////////////////////////////////////////////////////////////////
1038     interface ICacheFactoryService {
1039         // Lets not foce the optionsMap to have the capacity member. Even though
1040         // it's the ONLY option considered by the implementation today, a consumer
1041         // might find it useful to associate some other options to the cache object.
1042         //(cacheId: string, optionsMap?: { capacity: number; }): CacheObject;
1043         (cacheId: string, optionsMap?: { capacity: number; }): ICacheObject;
1044
1045         // Methods bellow are not documented
1046         info(): any;
1047         get(cacheId: string): ICacheObject;
1048     }
1049
1050     interface ICacheObject {
1051         info(): {
1052             id: string;
1053             size: number;
1054
1055             // Not garanteed to have, since it's a non-mandatory option
1056             //capacity: number;
1057         };
1058         put<T>(key: string, value?: T): T;
1059         get(key: string): any;
1060         remove(key: string): void;
1061         removeAll(): void;
1062         destroy(): void;
1063     }
1064
1065     ///////////////////////////////////////////////////////////////////////////
1066     // CompileService
1067     // see http://docs.angularjs.org/api/ng.$compile
1068     // see http://docs.angularjs.org/api/ng.$compileProvider
1069     ///////////////////////////////////////////////////////////////////////////
1070     interface ICompileService {
1071         (element: string, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
1072         (element: Element, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
1073         (element: JQuery, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
1074     }
1075
1076     interface ICompileProvider extends IServiceProvider {
1077         directive(name: string, directiveFactory: Function): ICompileProvider;
1078
1079         // Undocumented, but it is there...
1080         directive(directivesMap: any): ICompileProvider;
1081
1082         aHrefSanitizationWhitelist(): RegExp;
1083         aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider;
1084
1085         imgSrcSanitizationWhitelist(): RegExp;
1086         imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider;
1087
1088         debugInfoEnabled(enabled?: boolean): any;
1089     }
1090
1091     interface ICloneAttachFunction {
1092         // Let's hint but not force cloneAttachFn's signature
1093         (clonedElement?: JQuery, scope?: IScope): any;
1094     }
1095
1096     // This corresponds to the "publicLinkFn" returned by $compile.
1097     interface ITemplateLinkingFunction {
1098         (scope: IScope, cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;
1099     }
1100
1101     // This corresponds to $transclude (and also the transclude function passed to link).
1102     interface ITranscludeFunction {
1103         // If the scope is provided, then the cloneAttachFn must be as well.
1104         (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery;
1105         // If one argument is provided, then it's assumed to be the cloneAttachFn.
1106         (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;
1107     }
1108
1109     ///////////////////////////////////////////////////////////////////////////
1110     // ControllerService
1111     // see http://docs.angularjs.org/api/ng.$controller
1112     // see http://docs.angularjs.org/api/ng.$controllerProvider
1113     ///////////////////////////////////////////////////////////////////////////
1114     interface IControllerService {
1115         // Although the documentation doesn't state this, locals are optional
1116         (controllerConstructor: Function, locals?: any): any;
1117         (controllerName: string, locals?: any): any;
1118     }
1119
1120     interface IControllerProvider extends IServiceProvider {
1121         register(name: string, controllerConstructor: Function): void;
1122         register(name: string, dependencyAnnotatedConstructor: any[]): void;
1123         allowGlobals(): void;
1124     }
1125
1126     /**
1127      * HttpService
1128      * see http://docs.angularjs.org/api/ng/service/$http
1129      */
1130     interface IHttpService {
1131         /**
1132          * Object describing the request to be made and how it should be processed.
1133          */
1134         <T>(config: IRequestConfig): IHttpPromise<T>;
1135
1136         /**
1137          * Shortcut method to perform GET request.
1138          *
1139          * @param url Relative or absolute URL specifying the destination of the request
1140          * @param config Optional configuration object
1141          */
1142         get<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1143
1144         /**
1145          * Shortcut method to perform DELETE request.
1146          *
1147          * @param url Relative or absolute URL specifying the destination of the request
1148          * @param config Optional configuration object
1149          */
1150         delete<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1151
1152         /**
1153          * Shortcut method to perform HEAD request.
1154          *
1155          * @param url Relative or absolute URL specifying the destination of the request
1156          * @param config Optional configuration object
1157          */
1158         head<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1159
1160         /**
1161          * Shortcut method to perform JSONP request.
1162          *
1163          * @param url Relative or absolute URL specifying the destination of the request
1164          * @param config Optional configuration object
1165          */
1166         jsonp<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1167
1168         /**
1169          * Shortcut method to perform POST request.
1170          *
1171          * @param url Relative or absolute URL specifying the destination of the request
1172          * @param data Request content
1173          * @param config Optional configuration object
1174          */
1175         post<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
1176
1177         /**
1178          * Shortcut method to perform PUT request.
1179          *
1180          * @param url Relative or absolute URL specifying the destination of the request
1181          * @param data Request content
1182          * @param config Optional configuration object
1183          */
1184         put<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
1185
1186         /**
1187          * Shortcut method to perform PATCH request.
1188          *
1189          * @param url Relative or absolute URL specifying the destination of the request
1190          * @param data Request content
1191          * @param config Optional configuration object
1192          */
1193         patch<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
1194
1195         /**
1196          * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations.
1197          */
1198         defaults: IRequestConfig;
1199
1200         /**
1201          * Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes.
1202          */
1203         pendingRequests: any[];
1204     }
1205
1206     /**
1207      * Object describing the request to be made and how it should be processed.
1208      * see http://docs.angularjs.org/api/ng/service/$http#usage
1209      */
1210     interface IRequestShortcutConfig {
1211         /**
1212          * {Object.<string|Object>}
1213          * 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.
1214          */
1215         params?: any;
1216
1217         /**
1218          * 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.
1219          */
1220         headers?: any;
1221
1222         /**
1223          * Name of HTTP header to populate with the XSRF token.
1224          */
1225         xsrfHeaderName?: string;
1226
1227         /**
1228          * Name of cookie containing the XSRF token.
1229          */
1230         xsrfCookieName?: string;
1231
1232         /**
1233          * {boolean|Cache}
1234          * 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.
1235          */
1236         cache?: any;
1237
1238         /**
1239          * 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.
1240          */
1241         withCredentials?: boolean;
1242
1243         /**
1244          * {string|Object}
1245          * Data to be sent as the request message data.
1246          */
1247         data?: any;
1248
1249         /**
1250          * {function(data, headersGetter)|Array.<function(data, headersGetter)>}
1251          * 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.
1252          */
1253         transformRequest?: any;
1254
1255         /**
1256          * {function(data, headersGetter)|Array.<function(data, headersGetter)>}
1257          * 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.
1258          */
1259         transformResponse?: any;
1260
1261         /**
1262          * {number|Promise}
1263          * Timeout in milliseconds, or promise that should abort the request when resolved.
1264          */
1265         timeout?: any;
1266
1267         /**
1268          * See requestType.
1269          */
1270         responseType?: string;
1271     }
1272
1273     /**
1274      * Object describing the request to be made and how it should be processed.
1275      * see http://docs.angularjs.org/api/ng/service/$http#usage
1276      */
1277     interface IRequestConfig extends IRequestShortcutConfig {
1278         /**
1279          * HTTP method (e.g. 'GET', 'POST', etc)
1280          */
1281         method: string;
1282         /**
1283          * Absolute or relative URL of the resource that is being requested.
1284          */
1285         url: string;
1286     }
1287
1288     interface IHttpHeadersGetter {
1289         (): { [name: string]: string; };
1290         (headerName: string): string;
1291     }
1292
1293     interface IHttpPromiseCallback<T> {
1294         (data: T, status: number, headers: IHttpHeadersGetter, config: IRequestConfig): void;
1295     }
1296
1297     interface IHttpPromiseCallbackArg<T> {
1298         data?: T;
1299         status?: number;
1300         headers?: IHttpHeadersGetter;
1301         config?: IRequestConfig;
1302         statusText?: string;
1303     }
1304
1305     interface IHttpPromise<T> extends IPromise<IHttpPromiseCallbackArg<T>> {
1306         success(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
1307         error(callback: IHttpPromiseCallback<any>): IHttpPromise<T>;
1308     }
1309
1310     /**
1311     * Object that controls the defaults for $http provider
1312     * https://docs.angularjs.org/api/ng/service/$http#defaults
1313     */
1314     interface IHttpProviderDefaults {
1315         xsrfCookieName?: string;
1316         xsrfHeaderName?: string;
1317         withCredentials?: boolean;
1318         headers?: {
1319             common?: any;
1320             post?: any;
1321             put?: any;
1322             patch?: any;
1323         }
1324     }
1325
1326     interface IHttpProvider extends IServiceProvider {
1327         defaults: IHttpProviderDefaults;
1328         interceptors: any[];
1329         useApplyAsync(): boolean;
1330         useApplyAsync(value: boolean): IHttpProvider;
1331     }
1332
1333     ///////////////////////////////////////////////////////////////////////////
1334     // HttpBackendService
1335     // see http://docs.angularjs.org/api/ng.$httpBackend
1336     // You should never need to use this service directly.
1337     ///////////////////////////////////////////////////////////////////////////
1338     interface IHttpBackendService {
1339         // XXX Perhaps define callback signature in the future
1340         (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void;
1341     }
1342
1343     ///////////////////////////////////////////////////////////////////////////
1344     // InterpolateService
1345     // see http://docs.angularjs.org/api/ng.$interpolate
1346     // see http://docs.angularjs.org/api/ng.$interpolateProvider
1347     ///////////////////////////////////////////////////////////////////////////
1348     interface IInterpolateService {
1349         (text: string, mustHaveExpression?: boolean, trustedContext?: string, allOrNothing?: boolean): IInterpolationFunction;
1350         endSymbol(): string;
1351         startSymbol(): string;
1352     }
1353
1354     interface IInterpolationFunction {
1355         (context: any): string;
1356     }
1357
1358     interface IInterpolateProvider extends IServiceProvider {
1359         startSymbol(): string;
1360         startSymbol(value: string): IInterpolateProvider;
1361         endSymbol(): string;
1362         endSymbol(value: string): IInterpolateProvider;
1363     }
1364
1365     ///////////////////////////////////////////////////////////////////////////
1366     // TemplateCacheService
1367     // see http://docs.angularjs.org/api/ng.$templateCache
1368     ///////////////////////////////////////////////////////////////////////////
1369     interface ITemplateCacheService extends ICacheObject {}
1370
1371     ///////////////////////////////////////////////////////////////////////////
1372     // SCEService
1373     // see http://docs.angularjs.org/api/ng.$sce
1374     ///////////////////////////////////////////////////////////////////////////
1375     interface ISCEService {
1376         getTrusted(type: string, mayBeTrusted: any): any;
1377         getTrustedCss(value: any): any;
1378         getTrustedHtml(value: any): any;
1379         getTrustedJs(value: any): any;
1380         getTrustedResourceUrl(value: any): any;
1381         getTrustedUrl(value: any): any;
1382         parse(type: string, expression: string): (context: any, locals: any) => any;
1383         parseAsCss(expression: string): (context: any, locals: any) => any;
1384         parseAsHtml(expression: string): (context: any, locals: any) => any;
1385         parseAsJs(expression: string): (context: any, locals: any) => any;
1386         parseAsResourceUrl(expression: string): (context: any, locals: any) => any;
1387         parseAsUrl(expression: string): (context: any, locals: any) => any;
1388         trustAs(type: string, value: any): any;
1389         trustAsHtml(value: any): any;
1390         trustAsJs(value: any): any;
1391         trustAsResourceUrl(value: any): any;
1392         trustAsUrl(value: any): any;
1393         isEnabled(): boolean;
1394     }
1395
1396     ///////////////////////////////////////////////////////////////////////////
1397     // SCEProvider
1398     // see http://docs.angularjs.org/api/ng.$sceProvider
1399     ///////////////////////////////////////////////////////////////////////////
1400     interface ISCEProvider extends IServiceProvider {
1401         enabled(value: boolean): void;
1402     }
1403
1404     ///////////////////////////////////////////////////////////////////////////
1405     // SCEDelegateService
1406     // see http://docs.angularjs.org/api/ng.$sceDelegate
1407     ///////////////////////////////////////////////////////////////////////////
1408     interface ISCEDelegateService {
1409         getTrusted(type: string, mayBeTrusted: any): any;
1410         trustAs(type: string, value: any): any;
1411         valueOf(value: any): any;
1412     }
1413
1414
1415     ///////////////////////////////////////////////////////////////////////////
1416     // SCEDelegateProvider
1417     // see http://docs.angularjs.org/api/ng.$sceDelegateProvider
1418     ///////////////////////////////////////////////////////////////////////////
1419     interface ISCEDelegateProvider extends IServiceProvider {
1420         resourceUrlBlacklist(blacklist: any[]): void;
1421         resourceUrlWhitelist(whitelist: any[]): void;
1422     }
1423
1424     /**
1425      * $templateRequest service
1426      * see http://docs.angularjs.org/api/ng/service/$templateRequest
1427      */
1428     interface ITemplateRequestService {
1429         /**
1430          * Downloads a template using $http and, upon success, stores the
1431          * contents inside of $templateCache.
1432          *
1433          * If the HTTP request fails or the response data of the HTTP request is
1434          * empty then a $compile error will be thrown (unless
1435          * {ignoreRequestError} is set to true).
1436          *
1437          * @param tpl                  The template URL.
1438          * @param ignoreRequestError   Whether or not to ignore the exception
1439          *                             when the request fails or the template is
1440          *                             empty.
1441          *
1442          * @return   A promise whose value is the template content.
1443          */
1444         (tpl: string, ignoreRequestError?: boolean): IPromise<string>;
1445         /**
1446          * total amount of pending template requests being downloaded.
1447          * @type {number}
1448          */
1449         totalPendingRequests: number;
1450     }
1451
1452     ///////////////////////////////////////////////////////////////////////////
1453     // Directive
1454     // see http://docs.angularjs.org/api/ng.$compileProvider#directive
1455     // and http://docs.angularjs.org/guide/directive
1456     ///////////////////////////////////////////////////////////////////////////
1457
1458     interface IDirectiveFactory {
1459         (...args: any[]): IDirective;
1460     }
1461
1462     interface IDirectiveLinkFn {
1463         (
1464             scope: IScope,
1465             instanceElement: IAugmentedJQuery,
1466             instanceAttributes: IAttributes,
1467             controller: any,
1468             transclude: ITranscludeFunction
1469         ): void;
1470     }
1471
1472     interface IDirectivePrePost {
1473         pre?: IDirectiveLinkFn;
1474         post?: IDirectiveLinkFn;
1475     }
1476
1477     interface IDirectiveCompileFn {
1478         (
1479             templateElement: IAugmentedJQuery,
1480             templateAttributes: IAttributes,
1481             transclude: ITranscludeFunction
1482         ): IDirectivePrePost;
1483     }
1484
1485     interface IDirective {
1486         compile?: IDirectiveCompileFn;
1487         controller?: any;
1488         controllerAs?: string;
1489         bindToController?: boolean;
1490         link?: IDirectiveLinkFn | IDirectivePrePost;
1491         name?: string;
1492         priority?: number;
1493         replace?: boolean;
1494         require?: any;
1495         restrict?: string;
1496         scope?: any;
1497         template?: any;
1498         templateUrl?: any;
1499         terminal?: boolean;
1500         transclude?: any;
1501     }
1502
1503     /**
1504      * angular.element
1505      * when calling angular.element, angular returns a jQuery object,
1506      * augmented with additional methods like e.g. scope.
1507      * see: http://docs.angularjs.org/api/angular.element
1508      */
1509     interface IAugmentedJQueryStatic extends JQueryStatic {
1510         (selector: string, context?: any): IAugmentedJQuery;
1511         (element: Element): IAugmentedJQuery;
1512         (object: {}): IAugmentedJQuery;
1513         (elementArray: Element[]): IAugmentedJQuery;
1514         (object: JQuery): IAugmentedJQuery;
1515         (func: Function): IAugmentedJQuery;
1516         (array: any[]): IAugmentedJQuery;
1517         (): IAugmentedJQuery;
1518     }
1519
1520     interface IAugmentedJQuery extends JQuery {
1521         // TODO: events, how to define?
1522         //$destroy
1523
1524         find(selector: string): IAugmentedJQuery;
1525         find(element: any): IAugmentedJQuery;
1526         find(obj: JQuery): IAugmentedJQuery;
1527         controller(): any;
1528         controller(name: string): any;
1529         injector(): any;
1530         scope(): IScope;
1531         isolateScope(): IScope;
1532
1533         inheritedData(key: string, value: any): JQuery;
1534         inheritedData(obj: { [key: string]: any; }): JQuery;
1535         inheritedData(key?: string): any;
1536     }
1537
1538     ///////////////////////////////////////////////////////////////////////
1539     // AnimateService
1540     // see http://docs.angularjs.org/api/ng.$animate
1541     ///////////////////////////////////////////////////////////////////////
1542     interface IAnimateService {
1543         addClass(element: JQuery, className: string, done?: Function): IPromise<any>;
1544         enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void;
1545         leave(element: JQuery, done?: Function): void;
1546         move(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void;
1547         removeClass(element: JQuery, className: string, done?: Function): void;
1548     }
1549
1550     ///////////////////////////////////////////////////////////////////////////
1551     // AUTO module (angular.js)
1552     ///////////////////////////////////////////////////////////////////////////
1553     export module auto {
1554
1555         ///////////////////////////////////////////////////////////////////////
1556         // InjectorService
1557         // see http://docs.angularjs.org/api/AUTO.$injector
1558         ///////////////////////////////////////////////////////////////////////
1559         interface IInjectorService {
1560             annotate(fn: Function): string[];
1561             annotate(inlineAnnotatedFunction: any[]): string[];
1562             get(name: string): any;
1563             has(name: string): boolean;
1564             instantiate(typeConstructor: Function, locals?: any): any;
1565             invoke(inlineAnnotatedFunction: any[]): any;
1566             invoke(func: Function, context?: any, locals?: any): any;
1567         }
1568
1569         ///////////////////////////////////////////////////////////////////////
1570         // ProvideService
1571         // see http://docs.angularjs.org/api/AUTO.$provide
1572         ///////////////////////////////////////////////////////////////////////
1573         interface IProvideService {
1574             // Documentation says it returns the registered instance, but actual
1575             // implementation does not return anything.
1576             // constant(name: string, value: any): any;
1577             /**
1578              * 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.
1579              *
1580              * @param name The name of the constant.
1581              * @param value The constant value.
1582              */
1583             constant(name: string, value: any): void;
1584
1585             /**
1586              * 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.
1587              *
1588              * @param name The name of the service to decorate.
1589              * @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:
1590              *
1591              * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
1592              */
1593             decorator(name: string, decorator: Function): void;
1594             /**
1595              * 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.
1596              *
1597              * @param name The name of the service to decorate.
1598              * @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:
1599              *
1600              * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
1601              */
1602             decorator(name: string, inlineAnnotatedFunction: any[]): void;
1603             factory(name: string, serviceFactoryFunction: Function): IServiceProvider;
1604             factory(name: string, inlineAnnotatedFunction: any[]): IServiceProvider;
1605             provider(name: string, provider: IServiceProvider): IServiceProvider;
1606             provider(name: string, serviceProviderConstructor: Function): IServiceProvider;
1607             service(name: string, constructor: Function): IServiceProvider;
1608             value(name: string, value: any): IServiceProvider;
1609         }
1610
1611     }
1612 }