UNPKG

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