blob: edb1d69a916ab84a8dd9792fa03d908d986471fb [file] [log] [blame]
Matteo Scandolof6acdbe2016-12-13 10:29:37 -08001// Generated by typings
2// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/5f2450ba8001ed38c83eae3c0db93f0a3309180d/angularjs/angular.d.ts
3declare var angular: angular.IAngularStatic;
4
5// Support for painless dependency injection
6interface Function {
7 $inject?: string[];
8}
9
10// Collapse angular into ng
11import ng = angular;
12// Support AMD require
13declare module 'angular' {
14 export = angular;
15}
16
17///////////////////////////////////////////////////////////////////////////////
18// ng module (angular.js)
19///////////////////////////////////////////////////////////////////////////////
20declare namespace angular {
21
22 type Injectable<T extends Function> = T | (string | T)[];
23
24 // not directly implemented, but ensures that constructed class implements $get
25 interface IServiceProviderClass {
26 new (...args: any[]): IServiceProvider;
27 }
28
29 interface IServiceProviderFactory {
30 (...args: any[]): IServiceProvider;
31 }
32
33 // All service providers extend this interface
34 interface IServiceProvider {
35 $get: any;
36 }
37
38 interface IAngularBootstrapConfig {
39 strictDi?: boolean;
40 }
41
42 ///////////////////////////////////////////////////////////////////////////
43 // AngularStatic
44 // see http://docs.angularjs.org/api
45 ///////////////////////////////////////////////////////////////////////////
46 interface IAngularStatic {
47 bind(context: any, fn: Function, ...args: any[]): Function;
48
49 /**
50 * Use this function to manually start up angular application.
51 *
52 * @param element DOM element which is the root of angular application.
53 * @param modules An array of modules to load into the application.
54 * Each item in the array should be the name of a predefined module or a (DI annotated)
55 * function that will be invoked by the injector as a config block.
56 * @param config an object for defining configuration options for the application. The following keys are supported:
57 * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
58 */
59 bootstrap(element: string|Element|JQuery|Document, modules?: (string|Function|any[])[], config?: IAngularBootstrapConfig): auto.IInjectorService;
60
61 /**
62 * Creates a deep copy of source, which should be an object or an array.
63 *
64 * - If no destination is supplied, a copy of the object or array is created.
65 * - 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.
66 * - If source is not an object or array (inc. null and undefined), source is returned.
67 * - If source is identical to 'destination' an exception will be thrown.
68 *
69 * @param source The source that will be used to make a copy. Can be any type, including primitives, null, and undefined.
70 * @param destination Destination into which the source is copied. If provided, must be of the same type as source.
71 */
72 copy<T>(source: T, destination?: T): T;
73
74 /**
75 * Wraps a raw DOM element or HTML string as a jQuery element.
76 *
77 * 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."
78 */
79 element: JQueryStatic;
80 equals(value1: any, value2: any): boolean;
81 extend(destination: any, ...sources: any[]): any;
82
83 /**
84 * 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.
85 *
86 * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
87 *
88 * @param obj Object to iterate over.
89 * @param iterator Iterator function.
90 * @param context Object to become context (this) for the iterator function.
91 */
92 forEach<T>(obj: T[], iterator: (value: T, key: number) => any, context?: any): any;
93 /**
94 * 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.
95 *
96 * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
97 *
98 * @param obj Object to iterate over.
99 * @param iterator Iterator function.
100 * @param context Object to become context (this) for the iterator function.
101 */
102 forEach<T>(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any;
103 /**
104 * 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.
105 *
106 * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
107 *
108 * @param obj Object to iterate over.
109 * @param iterator Iterator function.
110 * @param context Object to become context (this) for the iterator function.
111 */
112 forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any;
113
114 fromJson(json: string): any;
115 identity<T>(arg?: T): T;
116 injector(modules?: any[], strictDi?: boolean): auto.IInjectorService;
117 isArray(value: any): value is Array<any>;
118 isDate(value: any): value is Date;
119 isDefined(value: any): boolean;
120 isElement(value: any): boolean;
121 isFunction(value: any): value is Function;
122 isNumber(value: any): value is number;
123 isObject(value: any): value is Object;
124 isObject<T>(value: any): value is T;
125 isString(value: any): value is string;
126 isUndefined(value: any): boolean;
127 lowercase(str: string): string;
128
129 /**
130 * 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).
131 *
132 * Unlike extend(), merge() recursively descends into object properties of source objects, performing a deep copy.
133 *
134 * @param dst Destination object.
135 * @param src Source object(s).
136 */
137 merge(dst: any, ...src: any[]): any;
138
139 /**
140 * 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.
141 *
142 * 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.
143 *
144 * @param name The name of the module to create or retrieve.
145 * @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.
146 * @param configFn Optional configuration function for the module.
147 */
148 module(
149 name: string,
150 requires?: string[],
151 configFn?: Function): IModule;
152
153 noop(...args: any[]): void;
154 reloadWithDebugInfo(): void;
155 toJson(obj: any, pretty?: boolean | number): string;
156 uppercase(str: string): string;
157 version: {
158 full: string;
159 major: number;
160 minor: number;
161 dot: number;
162 codeName: string;
163 };
164
165 /**
166 * If window.name contains prefix NG_DEFER_BOOTSTRAP! when angular.bootstrap is called, the bootstrap process will be paused until angular.resumeBootstrap() is called.
167 * @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.
168 */
169 resumeBootstrap?(extraModules?: string[]): ng.auto.IInjectorService;
170 }
171
172 ///////////////////////////////////////////////////////////////////////////
173 // Module
174 // see http://docs.angularjs.org/api/angular.Module
175 ///////////////////////////////////////////////////////////////////////////
176 interface IModule {
177 /**
178 * Use this method to register a component.
179 *
180 * @param name The name of the component.
181 * @param options A definition object passed into the component.
182 */
183 component(name: string, options: IComponentOptions): IModule;
184 /**
185 * Use this method to register work which needs to be performed on module loading.
186 *
187 * @param configFn Execute this function on module load. Useful for service configuration.
188 */
189 config(configFn: Function): IModule;
190 /**
191 * Use this method to register work which needs to be performed on module loading.
192 *
193 * @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration.
194 */
195 config(inlineAnnotatedFunction: any[]): IModule;
196 config(object: Object): IModule;
197 /**
198 * 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.
199 *
200 * @param name The name of the constant.
201 * @param value The constant value.
202 */
203 constant<T>(name: string, value: T): IModule;
204 constant(object: Object): IModule;
205 /**
206 * The $controller service is used by Angular to create new controllers.
207 *
208 * This provider allows controller registration via the register method.
209 *
210 * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
211 * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
212 */
213 controller(name: string, controllerConstructor: Injectable<IControllerConstructor>): IModule;
214 controller(object: {[name: string]: Injectable<IControllerConstructor>}): IModule;
215 /**
216 * Register a new directive with the compiler.
217 *
218 * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind)
219 * @param directiveFactory An injectable directive factory function.
220 */
221 directive(name: string, directiveFactory: Injectable<IDirectiveFactory>): IModule;
222 directive(object: {[directiveName: string]: Injectable<IDirectiveFactory>}): IModule;
223 /**
224 * 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.
225 *
226 * @param name The name of the instance.
227 * @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
228 */
229 factory(name: string, $getFn: Injectable<Function>): IModule;
230 factory(object: {[name: string]: Injectable<Function>}): IModule;
231 filter(name: string, filterFactoryFunction: Injectable<Function>): IModule;
232 filter(object: {[name: string]: Injectable<Function>}): IModule;
233 provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule;
234 provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule;
235 provider(name: string, inlineAnnotatedConstructor: any[]): IModule;
236 provider(name: string, providerObject: IServiceProvider): IModule;
237 provider(object: Object): IModule;
238 /**
239 * 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.
240 */
241 run(initializationFunction: Injectable<Function>): IModule;
242 /**
243 * Register a service constructor, which will be invoked with new to create the service instance. This is short for registering a service where its provider's $get property is a factory function that returns an instance instantiated by the injector from the service constructor function.
244 *
245 * @param name The name of the instance.
246 * @param serviceConstructor An injectable class (constructor function) that will be instantiated.
247 */
248 service(name: string, serviceConstructor: Injectable<Function>): IModule;
249 service(object: {[name: string]: Injectable<Function>}): IModule;
250 /**
251 * 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.
252
253 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.
254 *
255 * @param name The name of the instance.
256 * @param value The value.
257 */
258 value<T>(name: string, value: T): IModule;
259 value(object: Object): IModule;
260
261 /**
262 * 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.
263 * @param name The name of the service to decorate
264 * @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.
265 */
266 decorator(name: string, decorator: Injectable<Function>): IModule;
267
268 // Properties
269 name: string;
270 requires: string[];
271 }
272
273 ///////////////////////////////////////////////////////////////////////////
274 // Attributes
275 // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes
276 ///////////////////////////////////////////////////////////////////////////
277 interface IAttributes {
278 /**
279 * this is necessary to be able to access the scoped attributes. it's not very elegant
280 * because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way
281 * this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656
282 */
283 [name: string]: any;
284
285 /**
286 * Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with x- or data-) to its normalized, camelCase form.
287 *
288 * Also there is special case for Moz prefix starting with upper case letter.
289 *
290 * For further information check out the guide on @see https://docs.angularjs.org/guide/directive#matching-directives
291 */
292 $normalize(name: string): string;
293
294 /**
295 * Adds the CSS class value specified by the classVal parameter to the
296 * element. If animations are enabled then an animation will be triggered
297 * for the class addition.
298 */
299 $addClass(classVal: string): void;
300
301 /**
302 * Removes the CSS class value specified by the classVal parameter from the
303 * element. If animations are enabled then an animation will be triggered for
304 * the class removal.
305 */
306 $removeClass(classVal: string): void;
307
308 /**
309 * Adds and removes the appropriate CSS class values to the element based on the difference between
310 * the new and old CSS class values (specified as newClasses and oldClasses).
311 */
312 $updateClass(newClasses: string, oldClasses: string): void;
313
314 /**
315 * Set DOM element attribute value.
316 */
317 $set(key: string, value: any): void;
318
319 /**
320 * Observes an interpolated attribute.
321 * The observer function will be invoked once during the next $digest
322 * following compilation. The observer is then invoked whenever the
323 * interpolated value changes.
324 */
325 $observe<T>(name: string, fn: (value?: T) => any): Function;
326
327 /**
328 * A map of DOM element attribute names to the normalized name. This is needed
329 * to do reverse lookup from normalized name back to actual name.
330 */
331 $attr: Object;
332 }
333
334 /**
335 * form.FormController - type in module ng
336 * see https://docs.angularjs.org/api/ng/type/form.FormController
337 */
338 interface IFormController {
339
340 /**
341 * 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
342 */
343 [name: string]: any;
344
345 $pristine: boolean;
346 $dirty: boolean;
347 $valid: boolean;
348 $invalid: boolean;
349 $submitted: boolean;
350 $error: any;
351 $name: string;
352 $pending: any;
353 $addControl(control: INgModelController | IFormController): void;
354 $removeControl(control: INgModelController | IFormController): void;
355 $setValidity(validationErrorKey: string, isValid: boolean, control: INgModelController | IFormController): void;
356 $setDirty(): void;
357 $setPristine(): void;
358 $commitViewValue(): void;
359 $rollbackViewValue(): void;
360 $setSubmitted(): void;
361 $setUntouched(): void;
362 }
363
364 ///////////////////////////////////////////////////////////////////////////
365 // NgModelController
366 // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController
367 ///////////////////////////////////////////////////////////////////////////
368 interface INgModelController {
369 $render(): void;
370 $setValidity(validationErrorKey: string, isValid: boolean): void;
371 // Documentation states viewValue and modelValue to be a string but other
372 // types do work and it's common to use them.
373 $setViewValue(value: any, trigger?: string): void;
374 $setPristine(): void;
375 $setDirty(): void;
376 $validate(): void;
377 $setTouched(): void;
378 $setUntouched(): void;
379 $rollbackViewValue(): void;
380 $commitViewValue(): void;
381 $isEmpty(value: any): boolean;
382
383 $viewValue: any;
384
385 $modelValue: any;
386
387 $parsers: IModelParser[];
388 $formatters: IModelFormatter[];
389 $viewChangeListeners: IModelViewChangeListener[];
390 $error: any;
391 $name: string;
392
393 $touched: boolean;
394 $untouched: boolean;
395
396 $validators: IModelValidators;
397 $asyncValidators: IAsyncModelValidators;
398
399 $pending: any;
400 $pristine: boolean;
401 $dirty: boolean;
402 $valid: boolean;
403 $invalid: boolean;
404 }
405
406 //Allows tuning how model updates are done.
407 //https://docs.angularjs.org/api/ng/directive/ngModelOptions
408 interface INgModelOptions {
409 updateOn?: string;
410 debounce?: any;
411 allowInvalid?: boolean;
412 getterSetter?: boolean;
413 timezone?: string;
414 }
415
416 interface IModelValidators {
417 /**
418 * viewValue is any because it can be an object that is called in the view like $viewValue.name:$viewValue.subName
419 */
420 [index: string]: (modelValue: any, viewValue: any) => boolean;
421 }
422
423 interface IAsyncModelValidators {
424 [index: string]: (modelValue: any, viewValue: any) => IPromise<any>;
425 }
426
427 interface IModelParser {
428 (value: any): any;
429 }
430
431 interface IModelFormatter {
432 (value: any): any;
433 }
434
435 interface IModelViewChangeListener {
436 (): void;
437 }
438
439 /**
440 * $rootScope - $rootScopeProvider - service in module ng
441 * see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope
442 */
443 interface IRootScopeService {
444 [index: string]: any;
445
446 $apply(): any;
447 $apply(exp: string): any;
448 $apply(exp: (scope: IScope) => any): any;
449
450 $applyAsync(): any;
451 $applyAsync(exp: string): any;
452 $applyAsync(exp: (scope: IScope) => any): any;
453
454 /**
455 * Dispatches an event name downwards to all child scopes (and their children) notifying the registered $rootScope.Scope listeners.
456 *
457 * 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.
458 *
459 * Any exception emitted from the listeners will be passed onto the $exceptionHandler service.
460 *
461 * @param name Event name to broadcast.
462 * @param args Optional one or more arguments which will be passed onto the event listeners.
463 */
464 $broadcast(name: string, ...args: any[]): IAngularEvent;
465 $destroy(): void;
466 $digest(): void;
467 /**
468 * Dispatches an event name upwards through the scope hierarchy notifying the registered $rootScope.Scope listeners.
469 *
470 * 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.
471 *
472 * Any exception emitted from the listeners will be passed onto the $exceptionHandler service.
473 *
474 * @param name Event name to emit.
475 * @param args Optional one or more arguments which will be passed onto the event listeners.
476 */
477 $emit(name: string, ...args: any[]): IAngularEvent;
478
479 $eval(): any;
480 $eval(expression: string, locals?: Object): any;
481 $eval(expression: (scope: IScope) => any, locals?: Object): any;
482
483 $evalAsync(): void;
484 $evalAsync(expression: string): void;
485 $evalAsync(expression: (scope: IScope) => any): void;
486
487 // Defaults to false by the implementation checking strategy
488 $new(isolate?: boolean, parent?: IScope): IScope;
489
490 /**
491 * Listens on events of a given type. See $emit for discussion of event life cycle.
492 *
493 * The event listener function format is: function(event, args...).
494 *
495 * @param name Event name to listen on.
496 * @param listener Function to call when the event is emitted.
497 */
498 $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): () => void;
499
500 $watch(watchExpression: string, listener?: string, objectEquality?: boolean): () => void;
501 $watch<T>(watchExpression: string, listener?: (newValue: T, oldValue: T, scope: IScope) => any, objectEquality?: boolean): () => void;
502 $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): () => void;
503 $watch<T>(watchExpression: (scope: IScope) => T, listener?: (newValue: T, oldValue: T, scope: IScope) => any, objectEquality?: boolean): () => void;
504
505 $watchCollection<T>(watchExpression: string, listener: (newValue: T, oldValue: T, scope: IScope) => any): () => void;
506 $watchCollection<T>(watchExpression: (scope: IScope) => T, listener: (newValue: T, oldValue: T, scope: IScope) => any): () => void;
507
508 $watchGroup(watchExpressions: any[], listener: (newValue: any, oldValue: any, scope: IScope) => any): () => void;
509 $watchGroup(watchExpressions: { (scope: IScope): any }[], listener: (newValue: any, oldValue: any, scope: IScope) => any): () => void;
510
511 $parent: IScope;
512 $root: IRootScopeService;
513 $id: number;
514
515 // Hidden members
516 $$isolateBindings: any;
517 $$phase: any;
518 }
519
520 interface IScope extends IRootScopeService { }
521
522 /**
523 * $scope for ngRepeat directive.
524 * see https://docs.angularjs.org/api/ng/directive/ngRepeat
525 */
526 interface IRepeatScope extends IScope {
527
528 /**
529 * iterator offset of the repeated element (0..length-1).
530 */
531 $index: number;
532
533 /**
534 * true if the repeated element is first in the iterator.
535 */
536 $first: boolean;
537
538 /**
539 * true if the repeated element is between the first and last in the iterator.
540 */
541 $middle: boolean;
542
543 /**
544 * true if the repeated element is last in the iterator.
545 */
546 $last: boolean;
547
548 /**
549 * true if the iterator position $index is even (otherwise false).
550 */
551 $even: boolean;
552
553 /**
554 * true if the iterator position $index is odd (otherwise false).
555 */
556 $odd: boolean;
557
558 }
559
560 interface IAngularEvent {
561 /**
562 * the scope on which the event was $emit-ed or $broadcast-ed.
563 */
564 targetScope: IScope;
565 /**
566 * the scope that is currently handling the event. Once the event propagates through the scope hierarchy, this property is set to null.
567 */
568 currentScope: IScope;
569 /**
570 * name of the event.
571 */
572 name: string;
573 /**
574 * calling stopPropagation function will cancel further event propagation (available only for events that were $emit-ed).
575 */
576 stopPropagation?(): void;
577 /**
578 * calling preventDefault sets defaultPrevented flag to true.
579 */
580 preventDefault(): void;
581 /**
582 * true if preventDefault was called.
583 */
584 defaultPrevented: boolean;
585 }
586
587 ///////////////////////////////////////////////////////////////////////////
588 // WindowService
589 // see http://docs.angularjs.org/api/ng.$window
590 ///////////////////////////////////////////////////////////////////////////
591 interface IWindowService extends Window {
592 [key: string]: any;
593 }
594
595 ///////////////////////////////////////////////////////////////////////////
596 // TimeoutService
597 // see http://docs.angularjs.org/api/ng.$timeout
598 ///////////////////////////////////////////////////////////////////////////
599 interface ITimeoutService {
600 (delay?: number, invokeApply?: boolean): IPromise<void>;
601 <T>(fn: (...args: any[]) => T, delay?: number, invokeApply?: boolean, ...args: any[]): IPromise<T>;
602 cancel(promise?: IPromise<any>): boolean;
603 }
604
605 ///////////////////////////////////////////////////////////////////////////
606 // IntervalService
607 // see http://docs.angularjs.org/api/ng.$interval
608 ///////////////////////////////////////////////////////////////////////////
609 interface IIntervalService {
610 (func: Function, delay: number, count?: number, invokeApply?: boolean, ...args: any[]): IPromise<any>;
611 cancel(promise: IPromise<any>): boolean;
612 }
613
614 /**
615 * $filter - $filterProvider - service in module ng
616 *
617 * Filters are used for formatting data displayed to the user.
618 *
619 * see https://docs.angularjs.org/api/ng/service/$filter
620 */
621 interface IFilterService {
622 (name: 'filter'): IFilterFilter;
623 (name: 'currency'): IFilterCurrency;
624 (name: 'number'): IFilterNumber;
625 (name: 'date'): IFilterDate;
626 (name: 'json'): IFilterJson;
627 (name: 'lowercase'): IFilterLowercase;
628 (name: 'uppercase'): IFilterUppercase;
629 (name: 'limitTo'): IFilterLimitTo;
630 (name: 'orderBy'): IFilterOrderBy;
631 /**
632 * Usage:
633 * $filter(name);
634 *
635 * @param name Name of the filter function to retrieve
636 */
637 <T>(name: string): T;
638 }
639
640 interface IFilterFilter {
641 <T>(array: T[], expression: string | IFilterFilterPatternObject | IFilterFilterPredicateFunc<T>, comparator?: IFilterFilterComparatorFunc<T>|boolean): T[];
642 }
643
644 interface IFilterFilterPatternObject {
645 [name: string]: any;
646 }
647
648 interface IFilterFilterPredicateFunc<T> {
649 (value: T, index: number, array: T[]): boolean;
650 }
651
652 interface IFilterFilterComparatorFunc<T> {
653 (actual: T, expected: T): boolean;
654 }
655
656 interface IFilterCurrency {
657 /**
658 * Formats a number as a currency (ie $1,234.56). When no currency symbol is provided, default symbol for current locale is used.
659 * @param amount Input to filter.
660 * @param symbol Currency symbol or identifier to be displayed.
661 * @param fractionSize Number of decimal places to round the amount to, defaults to default max fraction size for current locale
662 * @return Formatted number
663 */
664 (amount: number, symbol?: string, fractionSize?: number): string;
665 }
666
667 interface IFilterNumber {
668 /**
669 * Formats a number as text.
670 * @param number Number to format.
671 * @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.
672 * @return Number rounded to decimalPlaces and places a “,” after each third digit.
673 */
674 (value: number|string, fractionSize?: number|string): string;
675 }
676
677 interface IFilterDate {
678 /**
679 * Formats date to a string based on the requested format.
680 *
681 * @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.
682 * @param format Formatting rules (see Description). If not specified, mediumDate is used.
683 * @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.
684 * @return Formatted string or the input if input is not recognized as date/millis.
685 */
686 (date: Date | number | string, format?: string, timezone?: string): string;
687 }
688
689 interface IFilterJson {
690 /**
691 * Allows you to convert a JavaScript object into JSON string.
692 * @param object Any JavaScript object (including arrays and primitive types) to filter.
693 * @param spacing The number of spaces to use per indentation, defaults to 2.
694 * @return JSON string.
695 */
696 (object: any, spacing?: number): string;
697 }
698
699 interface IFilterLowercase {
700 /**
701 * Converts string to lowercase.
702 */
703 (value: string): string;
704 }
705
706 interface IFilterUppercase {
707 /**
708 * Converts string to uppercase.
709 */
710 (value: string): string;
711 }
712
713 interface IFilterLimitTo {
714 /**
715 * 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.
716 * @param input Source array to be limited.
717 * @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.
718 * @param begin Index at which to begin limitation. As a negative index, begin indicates an offset from the end of input. Defaults to 0.
719 * @return A new sub-array of length limit or less if input array had less than limit elements.
720 */
721 <T>(input: T[], limit: string|number, begin?: string|number): T[];
722 /**
723 * 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.
724 * @param input Source string or number to be limited.
725 * @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.
726 * @param begin Index at which to begin limitation. As a negative index, begin indicates an offset from the end of input. Defaults to 0.
727 * @return A new substring of length limit or less if input had less than limit elements.
728 */
729 (input: string|number, limit: string|number, begin?: string|number): string;
730 }
731
732 interface IFilterOrderBy {
733 /**
734 * 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.
735 * @param array The array to sort.
736 * @param expression A predicate to be used by the comparator to determine the order of elements.
737 * @param reverse Reverse the order of the array.
738 * @return Reverse the order of the array.
739 */
740 <T>(array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean): T[];
741 }
742
743 /**
744 * $filterProvider - $filter - provider in module ng
745 *
746 * 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.
747 *
748 * see https://docs.angularjs.org/api/ng/provider/$filterProvider
749 */
750 interface IFilterProvider extends IServiceProvider {
751 /**
752 * register(name);
753 *
754 * @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).
755 */
756 register(name: string | {}): IServiceProvider;
757 }
758
759 ///////////////////////////////////////////////////////////////////////////
760 // LocaleService
761 // see http://docs.angularjs.org/api/ng.$locale
762 ///////////////////////////////////////////////////////////////////////////
763 interface ILocaleService {
764 id: string;
765
766 // These are not documented
767 // Check angular's i18n files for exemples
768 NUMBER_FORMATS: ILocaleNumberFormatDescriptor;
769 DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor;
770 pluralCat: (num: any) => string;
771 }
772
773 interface ILocaleNumberFormatDescriptor {
774 DECIMAL_SEP: string;
775 GROUP_SEP: string;
776 PATTERNS: ILocaleNumberPatternDescriptor[];
777 CURRENCY_SYM: string;
778 }
779
780 interface ILocaleNumberPatternDescriptor {
781 minInt: number;
782 minFrac: number;
783 maxFrac: number;
784 posPre: string;
785 posSuf: string;
786 negPre: string;
787 negSuf: string;
788 gSize: number;
789 lgSize: number;
790 }
791
792 interface ILocaleDateTimeFormatDescriptor {
793 MONTH: string[];
794 SHORTMONTH: string[];
795 DAY: string[];
796 SHORTDAY: string[];
797 AMPMS: string[];
798 medium: string;
799 short: string;
800 fullDate: string;
801 longDate: string;
802 mediumDate: string;
803 shortDate: string;
804 mediumTime: string;
805 shortTime: string;
806 }
807
808 ///////////////////////////////////////////////////////////////////////////
809 // LogService
810 // see http://docs.angularjs.org/api/ng.$log
811 // see http://docs.angularjs.org/api/ng.$logProvider
812 ///////////////////////////////////////////////////////////////////////////
813 interface ILogService {
814 debug: ILogCall;
815 error: ILogCall;
816 info: ILogCall;
817 log: ILogCall;
818 warn: ILogCall;
819 }
820
821 interface ILogProvider extends IServiceProvider {
822 debugEnabled(): boolean;
823 debugEnabled(enabled: boolean): ILogProvider;
824 }
825
826 // We define this as separate interface so we can reopen it later for
827 // the ngMock module.
828 interface ILogCall {
829 (...args: any[]): void;
830 }
831
832 ///////////////////////////////////////////////////////////////////////////
833 // ParseService
834 // see http://docs.angularjs.org/api/ng.$parse
835 // see http://docs.angularjs.org/api/ng.$parseProvider
836 ///////////////////////////////////////////////////////////////////////////
837 interface IParseService {
838 (expression: string, interceptorFn?: (value: any, scope: IScope, locals: any) => any, expensiveChecks?: boolean): ICompiledExpression;
839 }
840
841 interface IParseProvider {
842 logPromiseWarnings(): boolean;
843 logPromiseWarnings(value: boolean): IParseProvider;
844
845 unwrapPromises(): boolean;
846 unwrapPromises(value: boolean): IParseProvider;
847
848 /**
849 * Configure $parse service to add literal values that will be present as literal at expressions.
850 *
851 * @param literalName Token for the literal value. The literal name value must be a valid literal name.
852 * @param literalValue Value for this literal. All literal values must be primitives or `undefined`.
853 **/
854 addLiteral(literalName: string, literalValue: any): void;
855
856 /**
857 * Allows defining the set of characters that are allowed in Angular expressions. The function identifierStart will get called to know if a given character is a valid character to be the first character for an identifier. The function identifierContinue will get called to know if a given character is a valid character to be a follow-up identifier character. The functions identifierStart and identifierContinue will receive as arguments the single character to be identifier and the character code point. These arguments will be string and numeric. Keep in mind that the string parameter can be two characters long depending on the character representation. It is expected for the function to return true or false, whether that character is allowed or not.
858 * Since this function will be called extensivelly, keep the implementation of these functions fast, as the performance of these functions have a direct impact on the expressions parsing speed.
859 *
860 * @param identifierStart The function that will decide whether the given character is a valid identifier start character.
861 * @param identifierContinue The function that will decide whether the given character is a valid identifier continue character.
862 **/
863 setIdentifierFns(identifierStart?: (character: string, codePoint: number) => boolean,
864 identifierContinue?: (character: string, codePoint: number) => boolean): void;
865 }
866
867 interface ICompiledExpression {
868 (context: any, locals?: any): any;
869
870 literal: boolean;
871 constant: boolean;
872
873 // If value is not provided, undefined is gonna be used since the implementation
874 // does not check the parameter. Let's force a value for consistency. If consumer
875 // whants to undefine it, pass the undefined value explicitly.
876 assign(context: any, value: any): any;
877 }
878
879 /**
880 * $location - $locationProvider - service in module ng
881 * see https://docs.angularjs.org/api/ng/service/$location
882 */
883 interface ILocationService {
884 absUrl(): string;
885 hash(): string;
886 hash(newHash: string): ILocationService;
887 host(): string;
888
889 /**
890 * Return path of current url
891 */
892 path(): string;
893
894 /**
895 * Change path when called with parameter and return $location.
896 * Note: Path should always begin with forward slash (/), this method will add the forward slash if it is missing.
897 *
898 * @param path New path
899 */
900 path(path: string): ILocationService;
901
902 port(): number;
903 protocol(): string;
904 replace(): ILocationService;
905
906 /**
907 * Return search part (as object) of current url
908 */
909 search(): any;
910
911 /**
912 * Change search part when called with parameter and return $location.
913 *
914 * @param search When called with a single argument the method acts as a setter, setting the search component of $location to the specified value.
915 *
916 * If the argument is a hash object containing an array of values, these values will be encoded as duplicate search parameters in the url.
917 */
918 search(search: any): ILocationService;
919
920 /**
921 * Change search part when called with parameter and return $location.
922 *
923 * @param search New search params
924 * @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.
925 */
926 search(search: string, paramValue: string|number|string[]|boolean): ILocationService;
927
928 state(): any;
929 state(state: any): ILocationService;
930 url(): string;
931 url(url: string): ILocationService;
932 }
933
934 interface ILocationProvider extends IServiceProvider {
935 hashPrefix(): string;
936 hashPrefix(prefix: string): ILocationProvider;
937 html5Mode(): boolean;
938
939 // Documentation states that parameter is string, but
940 // implementation tests it as boolean, which makes more sense
941 // since this is a toggler
942 html5Mode(active: boolean): ILocationProvider;
943 html5Mode(mode: { enabled?: boolean; requireBase?: boolean; rewriteLinks?: boolean; }): ILocationProvider;
944 }
945
946 ///////////////////////////////////////////////////////////////////////////
947 // DocumentService
948 // see http://docs.angularjs.org/api/ng.$document
949 ///////////////////////////////////////////////////////////////////////////
950 interface IDocumentService extends JQuery {
951 // Must return intersection type for index signature compatibility with JQuery
952 [index: number]: HTMLElement & Document;
953 }
954
955 ///////////////////////////////////////////////////////////////////////////
956 // ExceptionHandlerService
957 // see http://docs.angularjs.org/api/ng.$exceptionHandler
958 ///////////////////////////////////////////////////////////////////////////
959 interface IExceptionHandlerService {
960 (exception: Error, cause?: string): void;
961 }
962
963 ///////////////////////////////////////////////////////////////////////////
964 // RootElementService
965 // see http://docs.angularjs.org/api/ng.$rootElement
966 ///////////////////////////////////////////////////////////////////////////
967 interface IRootElementService extends JQuery {}
968
969 interface IQResolveReject<T> {
970 (): void;
971 (value: T): void;
972 }
973 /**
974 * $q - service in module ng
975 * A promise/deferred implementation inspired by Kris Kowal's Q.
976 * See http://docs.angularjs.org/api/ng/service/$q
977 */
978 interface IQService {
979 new <T>(resolver: (resolve: IQResolveReject<T>) => any): IPromise<T>;
980 new <T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>;
981 <T>(resolver: (resolve: IQResolveReject<T>) => any): IPromise<T>;
982 <T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>;
983
984 /**
985 * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
986 *
987 * 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.
988 *
989 * @param promises An array of promises.
990 */
991 all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise <T4>, T5 | IPromise<T5>, T6 | IPromise<T6>, T7 | IPromise<T7>, T8 | IPromise<T8>, T9 | IPromise<T9>, T10 | IPromise<T10>]): IPromise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
992 all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise <T4>, T5 | IPromise<T5>, T6 | IPromise<T6>, T7 | IPromise<T7>, T8 | IPromise<T8>, T9 | IPromise<T9>]): IPromise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
993 all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise <T4>, T5 | IPromise<T5>, T6 | IPromise<T6>, T7 | IPromise<T7>, T8 | IPromise<T8>]): IPromise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
994 all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise <T4>, T5 | IPromise<T5>, T6 | IPromise<T6>, T7 | IPromise<T7>]): IPromise<[T1, T2, T3, T4, T5, T6, T7]>;
995 all<T1, T2, T3, T4, T5, T6>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise <T4>, T5 | IPromise<T5>, T6 | IPromise<T6>]): IPromise<[T1, T2, T3, T4, T5, T6]>;
996 all<T1, T2, T3, T4, T5>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise <T4>, T5 | IPromise<T5>]): IPromise<[T1, T2, T3, T4, T5]>;
997 all<T1, T2, T3, T4>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise <T4>]): IPromise<[T1, T2, T3, T4]>;
998 all<T1, T2, T3>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>]): IPromise<[T1, T2, T3]>;
999 all<T1, T2>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>]): IPromise<[T1, T2]>;
1000 all<TAll>(promises: IPromise<TAll>[]): IPromise<TAll[]>;
1001 /**
1002 * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
1003 *
1004 * 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.
1005 *
1006 * @param promises A hash of promises.
1007 */
1008 all(promises: { [id: string]: IPromise<any>; }): IPromise<{ [id: string]: any; }>;
1009 all<T extends {}>(promises: { [id: string]: IPromise<any>; }): IPromise<T>;
1010 /**
1011 * Creates a Deferred object which represents a task which will finish in the future.
1012 */
1013 defer<T>(): IDeferred<T>;
1014 /**
1015 * 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.
1016 *
1017 * 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.
1018 *
1019 * @param reason Constant, message, exception or an object representing the rejection reason.
1020 */
1021 reject(reason?: any): IPromise<any>;
1022 /**
1023 * 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.
1024 *
1025 * @param value Value or a promise
1026 */
1027 resolve<T>(value: IPromise<T>|T): IPromise<T>;
1028 /**
1029 * 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.
1030 */
1031 resolve(): IPromise<void>;
1032 /**
1033 * 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.
1034 *
1035 * @param value Value or a promise
1036 */
1037 when<T>(value: IPromise<T>|T): IPromise<T>;
1038 when<TResult, T>(value: IPromise<T>|T, successCallback: (promiseValue: T) => IPromise<TResult>|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>;
1039 /**
1040 * 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.
1041 */
1042 when(): IPromise<void>;
1043 }
1044
1045 interface IPromise<T> {
1046 /**
1047 * 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.
1048 * The successCallBack may return IPromise<void> for when a $q.reject() needs to be returned
1049 * 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.
1050 */
1051 then<TResult>(successCallback: (promiseValue: T) => IPromise<TResult>|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>;
1052
1053 /**
1054 * Shorthand for promise.then(null, errorCallback)
1055 */
1056 catch<TResult>(onRejected: (reason: any) => IPromise<TResult>|TResult): IPromise<TResult>;
1057
1058 /**
1059 * 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.
1060 *
1061 * 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.
1062 */
1063 finally(finallyCallback: () => any): IPromise<T>;
1064 }
1065
1066 interface IDeferred<T> {
1067 resolve(value?: T|IPromise<T>): void;
1068 reject(reason?: any): void;
1069 notify(state?: any): void;
1070 promise: IPromise<T>;
1071 }
1072
1073 ///////////////////////////////////////////////////////////////////////////
1074 // AnchorScrollService
1075 // see http://docs.angularjs.org/api/ng.$anchorScroll
1076 ///////////////////////////////////////////////////////////////////////////
1077 interface IAnchorScrollService {
1078 (): void;
1079 (hash: string): void;
1080 yOffset: any;
1081 }
1082
1083 interface IAnchorScrollProvider extends IServiceProvider {
1084 disableAutoScrolling(): void;
1085 }
1086
1087 /**
1088 * $cacheFactory - service in module ng
1089 *
1090 * Factory that constructs Cache objects and gives access to them.
1091 *
1092 * see https://docs.angularjs.org/api/ng/service/$cacheFactory
1093 */
1094 interface ICacheFactoryService {
1095 /**
1096 * Factory that constructs Cache objects and gives access to them.
1097 *
1098 * @param cacheId Name or id of the newly created cache.
1099 * @param optionsMap Options object that specifies the cache behavior. Properties:
1100 *
1101 * capacity — turns the cache into LRU cache.
1102 */
1103 (cacheId: string, optionsMap?: { capacity?: number; }): ICacheObject;
1104
1105 /**
1106 * Get information about all the caches that have been created.
1107 * @returns key-value map of cacheId to the result of calling cache#info
1108 */
1109 info(): any;
1110
1111 /**
1112 * Get access to a cache object by the cacheId used when it was created.
1113 *
1114 * @param cacheId Name or id of a cache to access.
1115 */
1116 get(cacheId: string): ICacheObject;
1117 }
1118
1119 /**
1120 * $cacheFactory.Cache - type in module ng
1121 *
1122 * A cache object used to store and retrieve data, primarily used by $http and the script directive to cache templates and other data.
1123 *
1124 * see https://docs.angularjs.org/api/ng/type/$cacheFactory.Cache
1125 */
1126 interface ICacheObject {
1127 /**
1128 * Retrieve information regarding a particular Cache.
1129 */
1130 info(): {
1131 /**
1132 * the id of the cache instance
1133 */
1134 id: string;
1135
1136 /**
1137 * the number of entries kept in the cache instance
1138 */
1139 size: number;
1140
1141 //...: any additional properties from the options object when creating the cache.
1142 };
1143
1144 /**
1145 * 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.
1146 *
1147 * It will not insert undefined values into the cache.
1148 *
1149 * @param key the key under which the cached data is stored.
1150 * @param value the value to store alongside the key. If it is undefined, the key will not be stored.
1151 */
1152 put<T>(key: string, value?: T): T;
1153
1154 /**
1155 * Retrieves named data stored in the Cache object.
1156 *
1157 * @param key the key of the data to be retrieved
1158 */
1159 get<T>(key: string): T;
1160
1161 /**
1162 * Removes an entry from the Cache object.
1163 *
1164 * @param key the key of the entry to be removed
1165 */
1166 remove(key: string): void;
1167
1168 /**
1169 * Clears the cache object of any entries.
1170 */
1171 removeAll(): void;
1172
1173 /**
1174 * Destroys the Cache object entirely, removing it from the $cacheFactory set.
1175 */
1176 destroy(): void;
1177 }
1178
1179 ///////////////////////////////////////////////////////////////////////////
1180 // CompileService
1181 // see http://docs.angularjs.org/api/ng.$compile
1182 // see http://docs.angularjs.org/api/ng.$compileProvider
1183 ///////////////////////////////////////////////////////////////////////////
1184 interface ICompileService {
1185 (element: string | Element | JQuery, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
1186 }
1187
1188 interface ICompileProvider extends IServiceProvider {
1189 directive(name: string, directiveFactory: Injectable<IDirectiveFactory>): ICompileProvider;
1190 directive(object: {[directiveName: string]: Injectable<IDirectiveFactory>}): ICompileProvider;
1191
1192 component(name: string, options: IComponentOptions): ICompileProvider;
1193
1194 aHrefSanitizationWhitelist(): RegExp;
1195 aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider;
1196
1197 imgSrcSanitizationWhitelist(): RegExp;
1198 imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider;
1199
1200 debugInfoEnabled(): boolean;
1201 debugInfoEnabled(enabled: boolean): ICompileProvider;
1202
1203 /**
1204 * Sets the number of times $onChanges hooks can trigger new changes before giving up and assuming that the model is unstable.
1205 * Increasing the TTL could have performance implications, so you should not change it without proper justification.
1206 * Default: 10.
1207 * See: https://docs.angularjs.org/api/ng/provider/$compileProvider#onChangesTtl
1208 */
1209 onChangesTtl(): number;
1210 onChangesTtl(limit: number): ICompileProvider;
1211
1212 /**
1213 * It indicates to the compiler whether or not directives on comments should be compiled.
1214 * It results in a compilation performance gain since the compiler doesn't have to check comments when looking for directives.
1215 * Defaults to true.
1216 * See: https://docs.angularjs.org/api/ng/provider/$compileProvider#commentDirectivesEnabled
1217 */
1218 commentDirectivesEnabled(): boolean;
1219 commentDirectivesEnabled(enabled: boolean): ICompileProvider;
1220
1221 /**
1222 * It indicates to the compiler whether or not directives on element classes should be compiled.
1223 * It results in a compilation performance gain since the compiler doesn't have to check element classes when looking for directives.
1224 * Defaults to true.
1225 * See: https://docs.angularjs.org/api/ng/provider/$compileProvider#cssClassDirectivesEnabled
1226 */
1227 cssClassDirectivesEnabled(): boolean;
1228 cssClassDirectivesEnabled(enabled: boolean): ICompileProvider;
1229 }
1230
1231 interface ICloneAttachFunction {
1232 // Let's hint but not force cloneAttachFn's signature
1233 (clonedElement?: JQuery, scope?: IScope): any;
1234 }
1235
1236 // This corresponds to the "publicLinkFn" returned by $compile.
1237 interface ITemplateLinkingFunction {
1238 (scope: IScope, cloneAttachFn?: ICloneAttachFunction): JQuery;
1239 }
1240
1241 /**
1242 * This corresponds to $transclude passed to controllers and to the transclude function passed to link functions.
1243 * https://docs.angularjs.org/api/ng/service/$compile#-controller-
1244 * http://teropa.info/blog/2015/06/09/transclusion.html
1245 */
1246 interface ITranscludeFunction {
1247 // If the scope is provided, then the cloneAttachFn must be as well.
1248 (scope: IScope, cloneAttachFn: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQuery;
1249 // If one argument is provided, then it's assumed to be the cloneAttachFn.
1250 (cloneAttachFn?: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQuery;
1251 }
1252
1253 ///////////////////////////////////////////////////////////////////////////
1254 // ControllerService
1255 // see http://docs.angularjs.org/api/ng.$controller
1256 // see http://docs.angularjs.org/api/ng.$controllerProvider
1257 ///////////////////////////////////////////////////////////////////////////
1258 interface IControllerService {
1259 // Although the documentation doesn't state this, locals are optional
1260 <T>(controllerConstructor: new (...args: any[]) => T, locals?: any, later?: boolean, ident?: string): T;
1261 <T>(controllerConstructor: Function, locals?: any, later?: boolean, ident?: string): T;
1262 <T>(controllerName: string, locals?: any, later?: boolean, ident?: string): T;
1263 }
1264
1265 interface IControllerProvider extends IServiceProvider {
1266 register(name: string, controllerConstructor: Function): void;
1267 register(name: string, dependencyAnnotatedConstructor: any[]): void;
1268 allowGlobals(): void;
1269 }
1270
1271 /**
1272 * xhrFactory
1273 * Replace or decorate this service to create your own custom XMLHttpRequest objects.
1274 * see https://docs.angularjs.org/api/ng/service/$xhrFactory
1275 */
1276 interface IXhrFactory<T> {
1277 (method: string, url: string): T;
1278 }
1279
1280 /**
1281 * HttpService
1282 * see http://docs.angularjs.org/api/ng/service/$http
1283 */
1284 interface IHttpService {
1285 /**
1286 * Object describing the request to be made and how it should be processed.
1287 */
1288 <T>(config: IRequestConfig): IHttpPromise<T>;
1289
1290 /**
1291 * Shortcut method to perform GET request.
1292 *
1293 * @param url Relative or absolute URL specifying the destination of the request
1294 * @param config Optional configuration object
1295 */
1296 get<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1297
1298 /**
1299 * Shortcut method to perform DELETE request.
1300 *
1301 * @param url Relative or absolute URL specifying the destination of the request
1302 * @param config Optional configuration object
1303 */
1304 delete<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1305
1306 /**
1307 * Shortcut method to perform HEAD request.
1308 *
1309 * @param url Relative or absolute URL specifying the destination of the request
1310 * @param config Optional configuration object
1311 */
1312 head<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1313
1314 /**
1315 * Shortcut method to perform JSONP request.
1316 *
1317 * @param url Relative or absolute URL specifying the destination of the request
1318 * @param config Optional configuration object
1319 */
1320 jsonp<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1321
1322 /**
1323 * Shortcut method to perform POST request.
1324 *
1325 * @param url Relative or absolute URL specifying the destination of the request
1326 * @param data Request content
1327 * @param config Optional configuration object
1328 */
1329 post<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
1330
1331 /**
1332 * Shortcut method to perform PUT request.
1333 *
1334 * @param url Relative or absolute URL specifying the destination of the request
1335 * @param data Request content
1336 * @param config Optional configuration object
1337 */
1338 put<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
1339
1340 /**
1341 * Shortcut method to perform PATCH request.
1342 *
1343 * @param url Relative or absolute URL specifying the destination of the request
1344 * @param data Request content
1345 * @param config Optional configuration object
1346 */
1347 patch<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
1348
1349 /**
1350 * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations.
1351 */
1352 defaults: IHttpProviderDefaults;
1353
1354 /**
1355 * Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes.
1356 */
1357 pendingRequests: IRequestConfig[];
1358 }
1359
1360 /**
1361 * Object describing the request to be made and how it should be processed.
1362 * see http://docs.angularjs.org/api/ng/service/$http#usage
1363 */
1364 interface IRequestShortcutConfig extends IHttpProviderDefaults {
1365 /**
1366 * {Object.<string|Object>}
1367 * 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.
1368 */
1369 params?: any;
1370
1371 /**
1372 * {string|Object}
1373 * Data to be sent as the request message data.
1374 */
1375 data?: any;
1376
1377 /**
1378 * Timeout in milliseconds, or promise that should abort the request when resolved.
1379 */
1380 timeout?: number|IPromise<any>;
1381
1382 /**
1383 * See [XMLHttpRequest.responseType]https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#xmlhttprequest-responsetype
1384 */
1385 responseType?: string;
1386 }
1387
1388 /**
1389 * Object describing the request to be made and how it should be processed.
1390 * see http://docs.angularjs.org/api/ng/service/$http#usage
1391 */
1392 interface IRequestConfig extends IRequestShortcutConfig {
1393 /**
1394 * HTTP method (e.g. 'GET', 'POST', etc)
1395 */
1396 method: string;
1397 /**
1398 * Absolute or relative URL of the resource that is being requested.
1399 */
1400 url: string;
1401 /**
1402 * Event listeners to be bound to the XMLHttpRequest object.
1403 * To bind events to the XMLHttpRequest upload object, use uploadEventHandlers. The handler will be called in the context of a $apply block.
1404 */
1405 eventHandlers?: { [type: string]: EventListenerOrEventListenerObject };
1406 /**
1407 * Event listeners to be bound to the XMLHttpRequest upload object.
1408 * To bind events to the XMLHttpRequest object, use eventHandlers. The handler will be called in the context of a $apply block.
1409 */
1410 uploadEventHandlers?: { [type: string]: EventListenerOrEventListenerObject };
1411 }
1412
1413 interface IHttpHeadersGetter {
1414 (): { [name: string]: string; };
1415 (headerName: string): string;
1416 }
1417
1418 interface IHttpPromiseCallback<T> {
1419 (data: T, status: number, headers: IHttpHeadersGetter, config: IRequestConfig): void;
1420 }
1421
1422 interface IHttpPromiseCallbackArg<T> {
1423 data?: T;
1424 status?: number;
1425 headers?: IHttpHeadersGetter;
1426 config?: IRequestConfig;
1427 statusText?: string;
1428 }
1429
1430 interface IHttpPromise<T> extends IPromise<IHttpPromiseCallbackArg<T>> {
1431 /**
1432 * The $http legacy promise methods success and error have been deprecated. Use the standard then method instead.
1433 * If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error.
1434 * @deprecated
1435 */
1436 success?(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
1437 /**
1438 * The $http legacy promise methods success and error have been deprecated. Use the standard then method instead.
1439 * If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error.
1440 * @deprecated
1441 */
1442 error?(callback: IHttpPromiseCallback<any>): IHttpPromise<T>;
1443 }
1444
1445 // See the jsdoc for transformData() at https://github.com/angular/angular.js/blob/master/src/ng/http.js#L228
1446 interface IHttpRequestTransformer {
1447 (data: any, headersGetter: IHttpHeadersGetter): any;
1448 }
1449
1450 // The definition of fields are the same as IHttpPromiseCallbackArg
1451 interface IHttpResponseTransformer {
1452 (data: any, headersGetter: IHttpHeadersGetter, status: number): any;
1453 }
1454
1455 type HttpHeaderType = {[requestType: string]:string|((config:IRequestConfig) => string)};
1456
1457 interface IHttpRequestConfigHeaders {
1458 [requestType: string]: any;
1459 common?: any;
1460 get?: any;
1461 post?: any;
1462 put?: any;
1463 patch?: any;
1464 }
1465
1466 /**
1467 * Object that controls the defaults for $http provider. Not all fields of IRequestShortcutConfig can be configured
1468 * via defaults and the docs do not say which. The following is based on the inspection of the source code.
1469 * https://docs.angularjs.org/api/ng/service/$http#defaults
1470 * https://docs.angularjs.org/api/ng/service/$http#usage
1471 * https://docs.angularjs.org/api/ng/provider/$httpProvider The properties section
1472 */
1473 interface IHttpProviderDefaults {
1474 /**
1475 * {boolean|Cache}
1476 * 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.
1477 */
1478 cache?: any;
1479
1480 /**
1481 * Transform function or an array of such functions. The transform function takes the http request body and
1482 * headers and returns its transformed (typically serialized) version.
1483 * @see {@link https://docs.angularjs.org/api/ng/service/$http#transforming-requests-and-responses}
1484 */
1485 transformRequest?: IHttpRequestTransformer |IHttpRequestTransformer[];
1486
1487 /**
1488 * Transform function or an array of such functions. The transform function takes the http response body and
1489 * headers and returns its transformed (typically deserialized) version.
1490 */
1491 transformResponse?: IHttpResponseTransformer | IHttpResponseTransformer[];
1492
1493 /**
1494 * Map of strings or functions which return strings representing HTTP headers to send to the server. If the
1495 * return value of a function is null, the header will not be sent.
1496 * The key of the map is the request verb in lower case. The "common" key applies to all requests.
1497 * @see {@link https://docs.angularjs.org/api/ng/service/$http#setting-http-headers}
1498 */
1499 headers?: IHttpRequestConfigHeaders;
1500
1501 /** Name of HTTP header to populate with the XSRF token. */
1502 xsrfHeaderName?: string;
1503
1504 /** Name of cookie containing the XSRF token. */
1505 xsrfCookieName?: string;
1506
1507 /**
1508 * 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.
1509 */
1510 withCredentials?: boolean;
1511
1512 /**
1513 * A function used to the prepare string representation of request parameters (specified as an object). If
1514 * specified as string, it is interpreted as a function registered with the $injector. Defaults to
1515 * $httpParamSerializer.
1516 */
1517 paramSerializer?: string | ((obj: any) => string);
1518 }
1519
1520 interface IHttpInterceptor {
1521 request?: (config: IRequestConfig) => IRequestConfig|IPromise<IRequestConfig>;
1522 requestError?: (rejection: any) => any;
1523 response?: <T>(response: IHttpPromiseCallbackArg<T>) => IPromise<IHttpPromiseCallbackArg<T>>|IHttpPromiseCallbackArg<T>;
1524 responseError?: (rejection: any) => any;
1525 }
1526
1527 interface IHttpInterceptorFactory {
1528 (...args: any[]): IHttpInterceptor;
1529 }
1530
1531 interface IHttpProvider extends IServiceProvider {
1532 defaults: IHttpProviderDefaults;
1533
1534 /**
1535 * Register service factories (names or implementations) for interceptors which are called before and after
1536 * each request.
1537 */
1538 interceptors: (string | Injectable<IHttpInterceptorFactory>)[];
1539 useApplyAsync(): boolean;
1540 useApplyAsync(value: boolean): IHttpProvider;
1541
1542 /**
1543 *
1544 * @param {boolean=} value If true, `$http` will return a normal promise without the `success` and `error` methods.
1545 * @returns {boolean|Object} If a value is specified, returns the $httpProvider for chaining.
1546 * otherwise, returns the current configured value.
1547 */
1548 useLegacyPromiseExtensions(value:boolean) : boolean | IHttpProvider;
1549 }
1550
1551 ///////////////////////////////////////////////////////////////////////////
1552 // HttpBackendService
1553 // see http://docs.angularjs.org/api/ng.$httpBackend
1554 // You should never need to use this service directly.
1555 ///////////////////////////////////////////////////////////////////////////
1556 interface IHttpBackendService {
1557 // XXX Perhaps define callback signature in the future
1558 (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void;
1559 }
1560
1561 ///////////////////////////////////////////////////////////////////////////
1562 // InterpolateService
1563 // see http://docs.angularjs.org/api/ng.$interpolate
1564 // see http://docs.angularjs.org/api/ng.$interpolateProvider
1565 ///////////////////////////////////////////////////////////////////////////
1566 interface IInterpolateService {
1567 (text: string, mustHaveExpression?: boolean, trustedContext?: string, allOrNothing?: boolean): IInterpolationFunction;
1568 endSymbol(): string;
1569 startSymbol(): string;
1570 }
1571
1572 interface IInterpolationFunction {
1573 (context: any): string;
1574 }
1575
1576 interface IInterpolateProvider extends IServiceProvider {
1577 startSymbol(): string;
1578 startSymbol(value: string): IInterpolateProvider;
1579 endSymbol(): string;
1580 endSymbol(value: string): IInterpolateProvider;
1581 }
1582
1583 ///////////////////////////////////////////////////////////////////////////
1584 // TemplateCacheService
1585 // see http://docs.angularjs.org/api/ng.$templateCache
1586 ///////////////////////////////////////////////////////////////////////////
1587 interface ITemplateCacheService extends ICacheObject {}
1588
1589 ///////////////////////////////////////////////////////////////////////////
1590 // SCEService
1591 // see http://docs.angularjs.org/api/ng.$sce
1592 ///////////////////////////////////////////////////////////////////////////
1593 interface ISCEService {
1594 getTrusted(type: string, mayBeTrusted: any): any;
1595 getTrustedCss(value: any): any;
1596 getTrustedHtml(value: any): any;
1597 getTrustedJs(value: any): any;
1598 getTrustedResourceUrl(value: any): any;
1599 getTrustedUrl(value: any): any;
1600 parse(type: string, expression: string): (context: any, locals: any) => any;
1601 parseAsCss(expression: string): (context: any, locals: any) => any;
1602 parseAsHtml(expression: string): (context: any, locals: any) => any;
1603 parseAsJs(expression: string): (context: any, locals: any) => any;
1604 parseAsResourceUrl(expression: string): (context: any, locals: any) => any;
1605 parseAsUrl(expression: string): (context: any, locals: any) => any;
1606 trustAs(type: string, value: any): any;
1607 trustAsHtml(value: any): any;
1608 trustAsJs(value: any): any;
1609 trustAsResourceUrl(value: any): any;
1610 trustAsUrl(value: any): any;
1611 isEnabled(): boolean;
1612 }
1613
1614 ///////////////////////////////////////////////////////////////////////////
1615 // SCEProvider
1616 // see http://docs.angularjs.org/api/ng.$sceProvider
1617 ///////////////////////////////////////////////////////////////////////////
1618 interface ISCEProvider extends IServiceProvider {
1619 enabled(value: boolean): void;
1620 }
1621
1622 ///////////////////////////////////////////////////////////////////////////
1623 // SCEDelegateService
1624 // see http://docs.angularjs.org/api/ng.$sceDelegate
1625 ///////////////////////////////////////////////////////////////////////////
1626 interface ISCEDelegateService {
1627 getTrusted(type: string, mayBeTrusted: any): any;
1628 trustAs(type: string, value: any): any;
1629 valueOf(value: any): any;
1630 }
1631
1632
1633 ///////////////////////////////////////////////////////////////////////////
1634 // SCEDelegateProvider
1635 // see http://docs.angularjs.org/api/ng.$sceDelegateProvider
1636 ///////////////////////////////////////////////////////////////////////////
1637 interface ISCEDelegateProvider extends IServiceProvider {
1638 resourceUrlBlacklist(blacklist: any[]): void;
1639 resourceUrlWhitelist(whitelist: any[]): void;
1640 resourceUrlBlacklist(): any[];
1641 resourceUrlWhitelist(): any[];
1642 }
1643
1644 /**
1645 * $templateRequest service
1646 * see http://docs.angularjs.org/api/ng/service/$templateRequest
1647 */
1648 interface ITemplateRequestService {
1649 /**
1650 * Downloads a template using $http and, upon success, stores the
1651 * contents inside of $templateCache.
1652 *
1653 * If the HTTP request fails or the response data of the HTTP request is
1654 * empty then a $compile error will be thrown (unless
1655 * {ignoreRequestError} is set to true).
1656 *
1657 * @param tpl The template URL.
1658 * @param ignoreRequestError Whether or not to ignore the exception
1659 * when the request fails or the template is
1660 * empty.
1661 *
1662 * @return A promise whose value is the template content.
1663 */
1664 (tpl: string, ignoreRequestError?: boolean): IPromise<string>;
1665 /**
1666 * total amount of pending template requests being downloaded.
1667 * @type {number}
1668 */
1669 totalPendingRequests: number;
1670 }
1671
1672 ///////////////////////////////////////////////////////////////////////////
1673 // Component
1674 // see http://angularjs.blogspot.com.br/2015/11/angularjs-15-beta2-and-14-releases.html
1675 // and http://toddmotto.com/exploring-the-angular-1-5-component-method/
1676 ///////////////////////////////////////////////////////////////////////////
1677 /**
1678 * Component definition object (a simplified directive definition object)
1679 */
1680 interface IComponentOptions {
1681 /**
1682 * Controller constructor function that should be associated with newly created scope or the name of a registered
1683 * controller if passed as a string. Empty function by default.
1684 * Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
1685 */
1686 controller?: string | Injectable<IControllerConstructor>;
1687 /**
1688 * An identifier name for a reference to the controller. If present, the controller will be published to its scope under
1689 * the specified name. If not present, this will default to '$ctrl'.
1690 */
1691 controllerAs?: string;
1692 /**
1693 * html template as a string or a function that returns an html template as a string which should be used as the
1694 * contents of this component. Empty string by default.
1695 * If template is a function, then it is injected with the following locals:
1696 * $element - Current element
1697 * $attrs - Current attributes object for the element
1698 * Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
1699 */
1700 template?: string | Injectable<(...args: any[]) => string>;
1701 /**
1702 * Path or function that returns a path to an html template that should be used as the contents of this component.
1703 * If templateUrl is a function, then it is injected with the following locals:
1704 * $element - Current element
1705 * $attrs - Current attributes object for the element
1706 * Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
1707 */
1708 templateUrl?: string | Injectable<(...args: any[]) => string>;
1709 /**
1710 * Define DOM attribute binding to component properties. Component properties are always bound to the component
1711 * controller and not to the scope.
1712 */
1713 bindings?: {[boundProperty: string]: string};
1714 /**
1715 * Whether transclusion is enabled. Disabled by default.
1716 */
1717 transclude?: boolean | {[slot: string]: string};
1718 /**
1719 * Requires the controllers of other directives and binds them to this component's controller.
1720 * The object keys specify the property names under which the required controllers (object values) will be bound.
1721 * Note that the required controllers will not be available during the instantiation of the controller,
1722 * but they are guaranteed to be available just before the $onInit method is executed!
1723 */
1724 require?: {[controller: string]: string};
1725 }
1726
1727 type IControllerConstructor =
1728 (new (...args: any[]) => IController) |
1729 // Instead of classes, plain functions are often used as controller constructors, especially in examples.
1730 ((...args: any[]) => (void | IController));
1731
1732 /**
1733 * Directive controllers have a well-defined lifecycle. Each controller can implement "lifecycle hooks". These are methods that
1734 * will be called by Angular at certain points in the life cycle of the directive.
1735 * https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
1736 * https://docs.angularjs.org/guide/component
1737 */
1738 interface IController {
1739 /**
1740 * Called on each controller after all the controllers on an element have been constructed and had their bindings
1741 * initialized (and before the pre & post linking functions for the directives on this element). This is a good
1742 * place to put initialization code for your controller.
1743 */
1744 $onInit?(): void;
1745 /**
1746 * Called on each turn of the digest cycle. Provides an opportunity to detect and act on changes.
1747 * Any actions that you wish to take in response to the changes that you detect must be invoked from this hook;
1748 * implementing this has no effect on when `$onChanges` is called. For example, this hook could be useful if you wish
1749 * to perform a deep equality check, or to check a `Dat`e object, changes to which would not be detected by Angular's
1750 * change detector and thus not trigger `$onChanges`. This hook is invoked with no arguments; if detecting changes,
1751 * you must store the previous value(s) for comparison to the current values.
1752 */
1753 $doCheck?(): void;
1754 /**
1755 * Called whenever one-way bindings are updated. The onChangesObj is a hash whose keys are the names of the bound
1756 * properties that have changed, and the values are an {@link IChangesObject} object of the form
1757 * { currentValue, previousValue, isFirstChange() }. Use this hook to trigger updates within a component such as
1758 * cloning the bound value to prevent accidental mutation of the outer value.
1759 */
1760 $onChanges?(onChangesObj: IOnChangesObject): void;
1761 /**
1762 * Called on a controller when its containing scope is destroyed. Use this hook for releasing external resources,
1763 * watches and event handlers.
1764 */
1765 $onDestroy?(): void;
1766 /**
1767 * Called after this controller's element and its children have been linked. Similar to the post-link function this
1768 * hook can be used to set up DOM event handlers and do direct DOM manipulation. Note that child elements that contain
1769 * templateUrl directives will not have been compiled and linked since they are waiting for their template to load
1770 * asynchronously and their own compilation and linking has been suspended until that occurs. This hook can be considered
1771 * analogous to the ngAfterViewInit and ngAfterContentInit hooks in Angular 2. Since the compilation process is rather
1772 * different in Angular 1 there is no direct mapping and care should be taken when upgrading.
1773 */
1774 $postLink?(): void;
1775 }
1776
1777 interface IOnChangesObject {
1778 [property: string]: IChangesObject<any>;
1779 }
1780
1781 interface IChangesObject<T> {
1782 currentValue: T;
1783 previousValue: T;
1784 isFirstChange(): boolean;
1785 }
1786
1787 ///////////////////////////////////////////////////////////////////////////
1788 // Directive
1789 // see http://docs.angularjs.org/api/ng.$compileProvider#directive
1790 // and http://docs.angularjs.org/guide/directive
1791 ///////////////////////////////////////////////////////////////////////////
1792
1793 interface IDirectiveFactory {
1794 (...args: any[]): IDirective | IDirectiveLinkFn;
1795 }
1796
1797 interface IDirectiveLinkFn {
1798 (
1799 scope: IScope,
1800 instanceElement: JQuery,
1801 instanceAttributes: IAttributes,
1802 controller?: IController | IController[] | {[key: string]: IController},
1803 transclude?: ITranscludeFunction
1804 ): void;
1805 }
1806
1807 interface IDirectivePrePost {
1808 pre?: IDirectiveLinkFn;
1809 post?: IDirectiveLinkFn;
1810 }
1811
1812 interface IDirectiveCompileFn {
1813 (
1814 templateElement: JQuery,
1815 templateAttributes: IAttributes,
1816 /**
1817 * @deprecated
1818 * Note: The transclude function that is passed to the compile function is deprecated,
1819 * as it e.g. does not know about the right outer scope. Please use the transclude function
1820 * that is passed to the link function instead.
1821 */
1822 transclude: ITranscludeFunction
1823 ): void | IDirectiveLinkFn | IDirectivePrePost;
1824 }
1825
1826 interface IDirective {
1827 compile?: IDirectiveCompileFn;
1828 controller?: string | Injectable<IControllerConstructor>;
1829 controllerAs?: string;
1830 /**
1831 * Deprecation warning: although bindings for non-ES6 class controllers are currently bound to this before
1832 * the controller constructor is called, this use is now deprecated. Please place initialization code that
1833 * relies upon bindings inside a $onInit method on the controller, instead.
1834 */
1835 bindToController?: boolean | {[boundProperty: string]: string};
1836 link?: IDirectiveLinkFn | IDirectivePrePost;
1837 multiElement?: boolean;
1838 priority?: number;
1839 /**
1840 * @deprecated
1841 */
1842 replace?: boolean;
1843 require?: string | string[] | {[controller: string]: string};
1844 restrict?: string;
1845 scope?: boolean | {[boundProperty: string]: string};
1846 template?: string | ((tElement: JQuery, tAttrs: IAttributes) => string);
1847 templateNamespace?: string;
1848 templateUrl?: string | ((tElement: JQuery, tAttrs: IAttributes) => string);
1849 terminal?: boolean;
1850 transclude?: boolean | 'element' | {[slot: string]: string};
1851 }
1852
1853 /**
1854 * These interfaces are kept for compatibility with older versions of these type definitions.
1855 * Actually, Angular doesn't create a special subclass of jQuery objects. It extends jQuery.prototype
1856 * like jQuery plugins do, that's why all jQuery objects have these Angular-specific methods, not
1857 * only those returned from angular.element.
1858 * See: http://docs.angularjs.org/api/angular.element
1859 */
1860 interface IAugmentedJQueryStatic extends JQueryStatic {}
1861 interface IAugmentedJQuery extends JQuery {}
1862
1863 /**
1864 * Same as IController. Keeping it for compatibility with older versions of these type definitions.
1865 */
1866 interface IComponentController extends IController {}
1867
1868 ///////////////////////////////////////////////////////////////////////////
1869 // AUTO module (angular.js)
1870 ///////////////////////////////////////////////////////////////////////////
1871 export module auto {
1872
1873 ///////////////////////////////////////////////////////////////////////
1874 // InjectorService
1875 // see http://docs.angularjs.org/api/AUTO.$injector
1876 ///////////////////////////////////////////////////////////////////////
1877 interface IInjectorService {
1878 annotate(fn: Function, strictDi?: boolean): string[];
1879 annotate(inlineAnnotatedFunction: any[]): string[];
1880 get<T>(name: string, caller?: string): T;
1881 get(name: '$anchorScroll'): IAnchorScrollService
1882 get(name: '$cacheFactory'): ICacheFactoryService
1883 get(name: '$compile'): ICompileService
1884 get(name: '$controller'): IControllerService
1885 get(name: '$document'): IDocumentService
1886 get(name: '$exceptionHandler'): IExceptionHandlerService
1887 get(name: '$filter'): IFilterService
1888 get(name: '$http'): IHttpService
1889 get(name: '$httpBackend'): IHttpBackendService
1890 get(name: '$httpParamSerializer'): IHttpParamSerializer
1891 get(name: '$httpParamSerializerJQLike'): IHttpParamSerializer
1892 get(name: '$interpolate'): IInterpolateService
1893 get(name: '$interval'): IIntervalService
1894 get(name: '$locale'): ILocaleService
1895 get(name: '$location'): ILocationService
1896 get(name: '$log'): ILogService
1897 get(name: '$parse'): IParseService
1898 get(name: '$q'): IQService
1899 get(name: '$rootElement'): IRootElementService
1900 get(name: '$rootScope'): IRootScopeService
1901 get(name: '$sce'): ISCEService
1902 get(name: '$sceDelegate'): ISCEDelegateService
1903 get(name: '$templateCache'): ITemplateCacheService
1904 get(name: '$templateRequest'): ITemplateRequestService
1905 get(name: '$timeout'): ITimeoutService
1906 get(name: '$window'): IWindowService
1907 get<T>(name: '$xhrFactory'): IXhrFactory<T>
1908 has(name: string): boolean;
1909 instantiate<T>(typeConstructor: Function, locals?: any): T;
1910 invoke(inlineAnnotatedFunction: any[]): any;
1911 invoke(func: Function, context?: any, locals?: any): any;
1912 strictDi: boolean;
1913 }
1914
1915 ///////////////////////////////////////////////////////////////////////
1916 // ProvideService
1917 // see http://docs.angularjs.org/api/AUTO.$provide
1918 ///////////////////////////////////////////////////////////////////////
1919 interface IProvideService {
1920 // Documentation says it returns the registered instance, but actual
1921 // implementation does not return anything.
1922 // constant(name: string, value: any): any;
1923 /**
1924 * 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.
1925 *
1926 * @param name The name of the constant.
1927 * @param value The constant value.
1928 */
1929 constant(name: string, value: any): void;
1930
1931 /**
1932 * 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.
1933 *
1934 * @param name The name of the service to decorate.
1935 * @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:
1936 *
1937 * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
1938 */
1939 decorator(name: string, decorator: Function): void;
1940 /**
1941 * 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.
1942 *
1943 * @param name The name of the service to decorate.
1944 * @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:
1945 *
1946 * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
1947 */
1948 decorator(name: string, inlineAnnotatedFunction: any[]): void;
1949 factory(name: string, serviceFactoryFunction: Function): IServiceProvider;
1950 factory(name: string, inlineAnnotatedFunction: any[]): IServiceProvider;
1951 provider(name: string, provider: IServiceProvider): IServiceProvider;
1952 provider(name: string, serviceProviderConstructor: Function): IServiceProvider;
1953 service(name: string, constructor: Function): IServiceProvider;
1954 service(name: string, inlineAnnotatedFunction: any[]): IServiceProvider;
1955 value(name: string, value: any): IServiceProvider;
1956 }
1957
1958 }
1959
1960 /**
1961 * $http params serializer that converts objects to strings
1962 * see https://docs.angularjs.org/api/ng/service/$httpParamSerializer
1963 */
1964 interface IHttpParamSerializer {
1965 (obj: Object): string;
1966 }
1967}
1968
1969interface JQuery {
1970 // TODO: events, how to define?
1971 //$destroy
1972
1973 find(element: any): JQuery;
1974 find(obj: JQuery): JQuery;
1975 controller(name?: string): any;
1976 injector(): ng.auto.IInjectorService;
1977 /** It's declared generic for custom scope interfaces */
1978 scope<T extends ng.IScope>(): T;
1979 isolateScope<T extends ng.IScope>(): T;
1980
1981 inheritedData(key: string, value: any): JQuery;
1982 inheritedData(obj: { [key: string]: any; }): JQuery;
1983 inheritedData(key?: string): any;
1984}