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> | undefined;
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 | undefined;
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 | undefined;
389 $pending?: { [validationErrorKey: string]: Array<INgModelController | IFormController> } | undefined;
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 | undefined;
432
433 $touched: boolean;
434 $untouched: boolean;
435
436 $validators: IModelValidators;
437 $asyncValidators: IAsyncModelValidators;
438
439 $pending?: { [validationErrorKey: string]: boolean } | undefined;
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 | undefined;
450 debounce?: number | { [key: string]: number; } | undefined;
451 allowInvalid?: boolean | undefined;
452 getterSetter?: boolean | undefined;
453 timezone?: string | undefined;
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 | undefined;
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 | undefined;
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 | undefined;
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 | undefined;
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 | undefined; requireBase?: boolean | undefined; rewriteLinks?: boolean | undefined; }): 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 | undefined; }): 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 * Sets the number of times $onChanges hooks can trigger new changes before giving up and assuming that the model is unstable.
1433 * Increasing the TTL could have performance implications, so you should not change it without proper justification.
1434 * Default: 10.
1435 * See: https://docs.angularjs.org/api/ng/provider/$compileProvider#onChangesTtl
1436 */
1437 onChangesTtl(): number;
1438 onChangesTtl(limit: number): ICompileProvider;
1439
1440 /**
1441 * It indicates to the compiler whether or not directives on comments should be compiled.
1442 * It results in a compilation performance gain since the compiler doesn't have to check comments when looking for directives.
1443 * Defaults to true.
1444 * See: https://docs.angularjs.org/api/ng/provider/$compileProvider#commentDirectivesEnabled
1445 */
1446 commentDirectivesEnabled(): boolean;
1447 commentDirectivesEnabled(enabled: boolean): ICompileProvider;
1448
1449 /**
1450 * It indicates to the compiler whether or not directives on element classes should be compiled.
1451 * It results in a compilation performance gain since the compiler doesn't have to check element classes when looking for directives.
1452 * Defaults to true.
1453 * See: https://docs.angularjs.org/api/ng/provider/$compileProvider#cssClassDirectivesEnabled
1454 */
1455 cssClassDirectivesEnabled(): boolean;
1456 cssClassDirectivesEnabled(enabled: boolean): ICompileProvider;
1457
1458 /**
1459 * Call this method to enable/disable strict component bindings check.
1460 * If enabled, the compiler will enforce that for all bindings of a
1461 * component that are not set as optional with ?, an attribute needs
1462 * to be provided on the component's HTML tag.
1463 * Defaults to false.
1464 * See: https://docs.angularjs.org/api/ng/provider/$compileProvider#strictComponentBindingsEnabled
1465 */
1466 strictComponentBindingsEnabled(): boolean;
1467 strictComponentBindingsEnabled(enabled: boolean): ICompileProvider;
1468 }
1469
1470 interface ICloneAttachFunction {
1471 // Let's hint but not force cloneAttachFn's signature
1472 (clonedElement?: JQLite, scope?: IScope): any;
1473 }
1474
1475 // This corresponds to the "publicLinkFn" returned by $compile.
1476 interface ITemplateLinkingFunction {
1477 (scope: IScope, cloneAttachFn?: ICloneAttachFunction, options?: ITemplateLinkingFunctionOptions): JQLite;
1478 }
1479
1480 interface ITemplateLinkingFunctionOptions {
1481 parentBoundTranscludeFn?: ITranscludeFunction | undefined;
1482 transcludeControllers?: {
1483 [controller: string]: { instance: IController }
1484 } | undefined;
1485 futureParentElement?: JQuery | undefined;
1486 }
1487
1488 /**
1489 * This corresponds to $transclude passed to controllers and to the transclude function passed to link functions.
1490 * https://docs.angularjs.org/api/ng/service/$compile#-controller-
1491 * http://teropa.info/blog/2015/06/09/transclusion.html
1492 */
1493 interface ITranscludeFunction {
1494 // If the scope is provided, then the cloneAttachFn must be as well.
1495 (scope: IScope, cloneAttachFn: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQLite;
1496 // If one argument is provided, then it's assumed to be the cloneAttachFn.
1497 (cloneAttachFn?: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQLite;
1498
1499 /**
1500 * Returns true if the specified slot contains content (i.e. one or more DOM nodes)
1501 */
1502 isSlotFilled(slotName: string): boolean;
1503 }
1504
1505 ///////////////////////////////////////////////////////////////////////////
1506 // ControllerService
1507 // see http://docs.angularjs.org/api/ng/service/$controller
1508 // see http://docs.angularjs.org/api/ng/provider/$controllerProvider
1509 ///////////////////////////////////////////////////////////////////////////
1510
1511 /**
1512 * The minimal local definitions required by $controller(ctrl, locals) calls.
1513 */
1514 interface IControllerLocals {
1515 $scope: ng.IScope;
1516 $element: JQuery;
1517 }
1518
1519 interface IControllerService {
1520 // Although the documentation doesn't state this, locals are optional
1521 <T>(controllerConstructor: new (...args: any[]) => T, locals?: any): T;
1522 <T>(controllerConstructor: (...args: any[]) => T, locals?: any): T;
1523 <T>(controllerName: string, locals?: any): T;
1524 }
1525
1526 interface IControllerProvider extends IServiceProvider {
1527 register(name: string, controllerConstructor: Function): void;
1528 register(name: string, dependencyAnnotatedConstructor: any[]): void;
1529 }
1530
1531 /**
1532 * xhrFactory
1533 * Replace or decorate this service to create your own custom XMLHttpRequest objects.
1534 * see https://docs.angularjs.org/api/ng/service/$xhrFactory
1535 */
1536 interface IXhrFactory<T> {
1537 (method: string, url: string): T;
1538 }
1539
1540 /**
1541 * HttpService
1542 * see http://docs.angularjs.org/api/ng/service/$http
1543 */
1544 interface IHttpService {
1545 /**
1546 * Object describing the request to be made and how it should be processed.
1547 */
1548 <T>(config: IRequestConfig): IHttpPromise<T>;
1549
1550 /**
1551 * Shortcut method to perform GET request.
1552 *
1553 * @param url Relative or absolute URL specifying the destination of the request
1554 * @param config Optional configuration object
1555 */
1556 get<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1557
1558 /**
1559 * Shortcut method to perform DELETE request.
1560 *
1561 * @param url Relative or absolute URL specifying the destination of the request
1562 * @param config Optional configuration object
1563 */
1564 delete<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1565
1566 /**
1567 * Shortcut method to perform HEAD request.
1568 *
1569 * @param url Relative or absolute URL specifying the destination of the request
1570 * @param config Optional configuration object
1571 */
1572 head<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1573
1574 /**
1575 * Shortcut method to perform JSONP request.
1576 *
1577 * @param url Relative or absolute URL specifying the destination of the request
1578 * @param config Optional configuration object
1579 */
1580 jsonp<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
1581
1582 /**
1583 * Shortcut method to perform POST request.
1584 *
1585 * @param url Relative or absolute URL specifying the destination of the request
1586 * @param data Request content
1587 * @param config Optional configuration object
1588 */
1589 post<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
1590
1591 /**
1592 * Shortcut method to perform PUT request.
1593 *
1594 * @param url Relative or absolute URL specifying the destination of the request
1595 * @param data Request content
1596 * @param config Optional configuration object
1597 */
1598 put<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
1599
1600 /**
1601 * Shortcut method to perform PATCH request.
1602 *
1603 * @param url Relative or absolute URL specifying the destination of the request
1604 * @param data Request content
1605 * @param config Optional configuration object
1606 */
1607 patch<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
1608
1609 /**
1610 * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations.
1611 */
1612 defaults: IHttpProviderDefaults;
1613
1614 /**
1615 * Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes.
1616 */
1617 pendingRequests: IRequestConfig[];
1618 }
1619
1620 /**
1621 * Object describing the request to be made and how it should be processed.
1622 * see http://docs.angularjs.org/api/ng/service/$http#usage
1623 */
1624 interface IRequestShortcutConfig extends IHttpProviderDefaults {
1625 /**
1626 * {Object.<string|Object>}
1627 * 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.
1628 */
1629 params?: any;
1630
1631 /**
1632 * {string|Object}
1633 * Data to be sent as the request message data.
1634 */
1635 data?: any;
1636
1637 /**
1638 * Timeout in milliseconds, or promise that should abort the request when resolved.
1639 */
1640 timeout?: number|IPromise<any> | undefined;
1641
1642 /**
1643 * See [XMLHttpRequest.responseType]https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#xmlhttprequest-responsetype
1644 */
1645 responseType?: string | undefined;
1646
1647 /**
1648 * 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.
1649 * If unspecified, $http.defaults.jsonpCallbackParam will be used by default. This property is only applicable to JSON-P requests.
1650 */
1651 jsonpCallbackParam?: string | undefined;
1652 }
1653
1654 /**
1655 * Object describing the request to be made and how it should be processed.
1656 * see http://docs.angularjs.org/api/ng/service/$http#usage
1657 */
1658 interface IRequestConfig extends IRequestShortcutConfig {
1659 /**
1660 * HTTP method (e.g. 'GET', 'POST', etc)
1661 */
1662 method: string;
1663 /**
1664 * Absolute or relative URL of the resource that is being requested.
1665 */
1666 url: string;
1667 /**
1668 * Event listeners to be bound to the XMLHttpRequest object.
1669 * To bind events to the XMLHttpRequest upload object, use uploadEventHandlers. The handler will be called in the context of a $apply block.
1670 */
1671 eventHandlers?: { [type: string]: EventListenerOrEventListenerObject } | undefined;
1672 /**
1673 * Event listeners to be bound to the XMLHttpRequest upload object.
1674 * To bind events to the XMLHttpRequest object, use eventHandlers. The handler will be called in the context of a $apply block.
1675 */
1676 uploadEventHandlers?: { [type: string]: EventListenerOrEventListenerObject } | undefined;
1677 }
1678
1679 interface IHttpHeadersGetter {
1680 (): { [name: string]: string; };
1681 (headerName: string): string;
1682 }
1683
1684 interface IHttpPromiseCallback<T> {
1685 (data: T, status: number, headers: IHttpHeadersGetter, config: IRequestConfig): void;
1686 }
1687
1688 interface IHttpResponse<T> {
1689 data: T;
1690 status: number;
1691 headers: IHttpHeadersGetter;
1692 config: IRequestConfig;
1693 statusText: string;
1694 /** Added in AngularJS 1.6.6 */
1695 xhrStatus: 'complete' | 'error' | 'timeout' | 'abort';
1696 }
1697
1698 /** @deprecated The old name of IHttpResponse. Kept for compatibility. */
1699 type IHttpPromiseCallbackArg<T> = IHttpResponse<T>;
1700
1701 type IHttpPromise<T> = IPromise<IHttpResponse<T>>;
1702
1703 // See the jsdoc for transformData() at https://github.com/angular/angular.js/blob/master/src/ng/http.js#L228
1704 interface IHttpRequestTransformer {
1705 (data: any, headersGetter: IHttpHeadersGetter): any;
1706 }
1707
1708 // The definition of fields are the same as IHttpResponse
1709 interface IHttpResponseTransformer {
1710 (data: any, headersGetter: IHttpHeadersGetter, status: number): any;
1711 }
1712
1713 interface HttpHeaderType {
1714 [requestType: string]: string|((config: IRequestConfig) => string);
1715 }
1716
1717 interface IHttpRequestConfigHeaders {
1718 [requestType: string]: any;
1719 common?: any;
1720 get?: any;
1721 post?: any;
1722 put?: any;
1723 patch?: any;
1724 }
1725
1726 /**
1727 * Object that controls the defaults for $http provider. Not all fields of IRequestShortcutConfig can be configured
1728 * via defaults and the docs do not say which. The following is based on the inspection of the source code.
1729 * https://docs.angularjs.org/api/ng/service/$http#defaults
1730 * https://docs.angularjs.org/api/ng/service/$http#usage
1731 * https://docs.angularjs.org/api/ng/provider/$httpProvider The properties section
1732 */
1733 interface IHttpProviderDefaults {
1734 /**
1735 * {boolean|Cache}
1736 * 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.
1737 */
1738 cache?: any;
1739
1740 /**
1741 * Transform function or an array of such functions. The transform function takes the http request body and
1742 * headers and returns its transformed (typically serialized) version.
1743 * @see {@link https://docs.angularjs.org/api/ng/service/$http#transforming-requests-and-responses}
1744 */
1745 transformRequest?: IHttpRequestTransformer |IHttpRequestTransformer[] | undefined;
1746
1747 /**
1748 * Transform function or an array of such functions. The transform function takes the http response body and
1749 * headers and returns its transformed (typically deserialized) version.
1750 */
1751 transformResponse?: IHttpResponseTransformer | IHttpResponseTransformer[] | undefined;
1752
1753 /**
1754 * Map of strings or functions which return strings representing HTTP headers to send to the server. If the
1755 * return value of a function is null, the header will not be sent.
1756 * The key of the map is the request verb in lower case. The "common" key applies to all requests.
1757 * @see {@link https://docs.angularjs.org/api/ng/service/$http#setting-http-headers}
1758 */
1759 headers?: IHttpRequestConfigHeaders | undefined;
1760
1761 /** Name of HTTP header to populate with the XSRF token. */
1762 xsrfHeaderName?: string | undefined;
1763
1764 /** Name of cookie containing the XSRF token. */
1765 xsrfCookieName?: string | undefined;
1766
1767 /**
1768 * 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.
1769 */
1770 withCredentials?: boolean | undefined;
1771
1772 /**
1773 * A function used to the prepare string representation of request parameters (specified as an object). If
1774 * specified as string, it is interpreted as a function registered with the $injector. Defaults to
1775 * $httpParamSerializer.
1776 */
1777 paramSerializer?: string | ((obj: any) => string) | undefined;
1778 }
1779
1780 interface IHttpInterceptor {
1781 request?(config: IRequestConfig): IRequestConfig | IPromise<IRequestConfig>;
1782 requestError?(rejection: any): IRequestConfig | IPromise<IRequestConfig>;
1783 response?<T>(response: IHttpResponse<T>): IPromise<IHttpResponse<T>> | IHttpResponse<T>;
1784 responseError?<T>(rejection: any): IPromise<IHttpResponse<T>> | IHttpResponse<T>;
1785 }
1786
1787 interface IHttpInterceptorFactory {
1788 (...args: any[]): IHttpInterceptor;
1789 }
1790
1791 interface IHttpProvider extends IServiceProvider {
1792 defaults: IHttpProviderDefaults;
1793
1794 /**
1795 * Register service factories (names or implementations) for interceptors which are called before and after
1796 * each request.
1797 */
1798 interceptors: Array<string | Injectable<IHttpInterceptorFactory>>;
1799 useApplyAsync(): boolean;
1800 useApplyAsync(value: boolean): IHttpProvider;
1801
1802 /** @deprecated The old name of xsrfTrustedOrigins. Kept for compatibility. */
1803 xsrfWhitelistedOrigins: string[];
1804 /**
1805 * Array containing URLs whose origins are trusted to receive the XSRF token.
1806 */
1807 xsrfTrustedOrigins: string[];
1808 }
1809
1810 ///////////////////////////////////////////////////////////////////////////
1811 // HttpBackendService
1812 // see http://docs.angularjs.org/api/ng/service/$httpBackend
1813 // You should never need to use this service directly.
1814 ///////////////////////////////////////////////////////////////////////////
1815 interface IHttpBackendService {
1816 // XXX Perhaps define callback signature in the future
1817 (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void;
1818 }
1819
1820 ///////////////////////////////////////////////////////////////////////////
1821 // InterpolateService
1822 // see http://docs.angularjs.org/api/ng/service/$interpolate
1823 // see http://docs.angularjs.org/api/ng/provider/$interpolateProvider
1824 ///////////////////////////////////////////////////////////////////////////
1825 interface IInterpolateService {
1826 (text: string, mustHaveExpression?: boolean, trustedContext?: string, allOrNothing?: boolean): IInterpolationFunction;
1827 endSymbol(): string;
1828 startSymbol(): string;
1829 }
1830
1831 interface IInterpolationFunction {
1832 (context: any): string;
1833 }
1834
1835 interface IInterpolateProvider extends IServiceProvider {
1836 startSymbol(): string;
1837 startSymbol(value: string): IInterpolateProvider;
1838 endSymbol(): string;
1839 endSymbol(value: string): IInterpolateProvider;
1840 }
1841
1842 ///////////////////////////////////////////////////////////////////////////
1843 // TemplateCacheService
1844 // see http://docs.angularjs.org/api/ng/service/$templateCache
1845 ///////////////////////////////////////////////////////////////////////////
1846 interface ITemplateCacheService extends ICacheObject {}
1847
1848 ///////////////////////////////////////////////////////////////////////////
1849 // SCEService
1850 // see http://docs.angularjs.org/api/ng/service/$sce
1851 ///////////////////////////////////////////////////////////////////////////
1852 interface ISCEService {
1853 getTrusted(type: string, mayBeTrusted: any): any;
1854 getTrustedCss(value: any): any;
1855 getTrustedHtml(value: any): any;
1856 getTrustedJs(value: any): any;
1857 getTrustedResourceUrl(value: any): any;
1858 getTrustedUrl(value: any): any;
1859 parse(type: string, expression: string): (context: any, locals: any) => any;
1860 parseAsCss(expression: string): (context: any, locals: any) => any;
1861 parseAsHtml(expression: string): (context: any, locals: any) => any;
1862 parseAsJs(expression: string): (context: any, locals: any) => any;
1863 parseAsResourceUrl(expression: string): (context: any, locals: any) => any;
1864 parseAsUrl(expression: string): (context: any, locals: any) => any;
1865 trustAs(type: string, value: any): any;
1866 trustAsHtml(value: any): any;
1867 trustAsJs(value: any): any;
1868 trustAsResourceUrl(value: any): any;
1869 trustAsUrl(value: any): any;
1870 isEnabled(): boolean;
1871 }
1872
1873 ///////////////////////////////////////////////////////////////////////////
1874 // SCEProvider
1875 // see http://docs.angularjs.org/api/ng/provider/$sceProvider
1876 ///////////////////////////////////////////////////////////////////////////
1877 interface ISCEProvider extends IServiceProvider {
1878 enabled(value: boolean): void;
1879 }
1880
1881 ///////////////////////////////////////////////////////////////////////////
1882 // SCEDelegateService
1883 // see http://docs.angularjs.org/api/ng/service/$sceDelegate
1884 ///////////////////////////////////////////////////////////////////////////
1885 interface ISCEDelegateService {
1886 getTrusted(type: string, mayBeTrusted: any): any;
1887 trustAs(type: string, value: any): any;
1888 valueOf(value: any): any;
1889 }
1890
1891 ///////////////////////////////////////////////////////////////////////////
1892 // SCEDelegateProvider
1893 // see http://docs.angularjs.org/api/ng/provider/$sceDelegateProvider
1894 ///////////////////////////////////////////////////////////////////////////
1895 interface ISCEDelegateProvider extends IServiceProvider {
1896 /** @deprecated since 1.8.1 */
1897 resourceUrlBlacklist(): any[];
1898 /** @deprecated since 1.8.1 */
1899 resourceUrlBlacklist(bannedList: any[]): void;
1900 bannedResourceUrlList(): any[];
1901 bannedResourceUrlList(bannedList: any[]): void;
1902 /** @deprecated since 1.8.1 */
1903 resourceUrlWhitelist(): any[];
1904 /** @deprecated since 1.8.1 */
1905 resourceUrlWhitelist(trustedList: any[]): void;
1906 trustedResourceUrlList(): any[];
1907 trustedResourceUrlList(trustedList: any[]): void;
1908 }
1909
1910 /**
1911 * $templateRequest service
1912 * see http://docs.angularjs.org/api/ng/service/$templateRequest
1913 */
1914 interface ITemplateRequestService {
1915 /**
1916 * Downloads a template using $http and, upon success, stores the
1917 * contents inside of $templateCache.
1918 *
1919 * If the HTTP request fails or the response data of the HTTP request is
1920 * empty then a $compile error will be thrown (unless
1921 * {ignoreRequestError} is set to true).
1922 *
1923 * @param tpl The template URL.
1924 * @param ignoreRequestError Whether or not to ignore the exception
1925 * when the request fails or the template is
1926 * empty.
1927 *
1928 * @return A promise whose value is the template content.
1929 */
1930 (tpl: string, ignoreRequestError?: boolean): IPromise<string>;
1931 /**
1932 * total amount of pending template requests being downloaded.
1933 */
1934 totalPendingRequests: number;
1935 }
1936
1937 ///////////////////////////////////////////////////////////////////////////
1938 // Component
1939 // see http://angularjs.blogspot.com.br/2015/11/angularjs-15-beta2-and-14-releases.html
1940 // and http://toddmotto.com/exploring-the-angular-1-5-component-method/
1941 ///////////////////////////////////////////////////////////////////////////
1942 /**
1943 * Component definition object (a simplified directive definition object)
1944 */
1945 interface IComponentOptions {
1946 /**
1947 * Controller constructor function that should be associated with newly created scope or the name of a registered
1948 * controller if passed as a string. Empty function by default.
1949 * Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
1950 */
1951 controller?: string | Injectable<IControllerConstructor> | undefined;
1952 /**
1953 * An identifier name for a reference to the controller. If present, the controller will be published to its scope under
1954 * the specified name. If not present, this will default to '$ctrl'.
1955 */
1956 controllerAs?: string | undefined;
1957 /**
1958 * html template as a string or a function that returns an html template as a string which should be used as the
1959 * contents of this component. Empty string by default.
1960 * If template is a function, then it is injected with the following locals:
1961 * $element - Current element
1962 * $attrs - Current attributes object for the element
1963 * Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
1964 */
1965 template?: string | Injectable<(...args: any[]) => string> | undefined;
1966 /**
1967 * Path or function that returns a path to an html template that should be used as the contents of this component.
1968 * If templateUrl is a function, then it is injected with the following locals:
1969 * $element - Current element
1970 * $attrs - Current attributes object for the element
1971 * Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
1972 */
1973 templateUrl?: string | Injectable<(...args: any[]) => string> | undefined;
1974 /**
1975 * Define DOM attribute binding to component properties. Component properties are always bound to the component
1976 * controller and not to the scope.
1977 */
1978 bindings?: {[boundProperty: string]: string} | undefined;
1979 /**
1980 * Whether transclusion is enabled. Disabled by default.
1981 */
1982 transclude?: boolean | {[slot: string]: string} | undefined;
1983 /**
1984 * Requires the controllers of other directives and binds them to this component's controller.
1985 * The object keys specify the property names under which the required controllers (object values) will be bound.
1986 * Note that the required controllers will not be available during the instantiation of the controller,
1987 * but they are guaranteed to be available just before the $onInit method is executed!
1988 */
1989 require?: {[controller: string]: string} | undefined;
1990 }
1991
1992 type IControllerConstructor =
1993 (new (...args: any[]) => IController) |
1994 // Instead of classes, plain functions are often used as controller constructors, especially in examples.
1995 ((...args: any[]) => (void | IController));
1996
1997 /**
1998 * Directive controllers have a well-defined lifecycle. Each controller can implement "lifecycle hooks". These are methods that
1999 * will be called by Angular at certain points in the life cycle of the directive.
2000 * https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
2001 * https://docs.angularjs.org/guide/component
2002 */
2003 interface IController {
2004 /**
2005 * Called on each controller after all the controllers on an element have been constructed and had their bindings
2006 * initialized (and before the pre & post linking functions for the directives on this element). This is a good
2007 * place to put initialization code for your controller.
2008 */
2009 $onInit?(): void;
2010 /**
2011 * Called on each turn of the digest cycle. Provides an opportunity to detect and act on changes.
2012 * Any actions that you wish to take in response to the changes that you detect must be invoked from this hook;
2013 * implementing this has no effect on when `$onChanges` is called. For example, this hook could be useful if you wish
2014 * to perform a deep equality check, or to check a `Dat`e object, changes to which would not be detected by Angular's
2015 * change detector and thus not trigger `$onChanges`. This hook is invoked with no arguments; if detecting changes,
2016 * you must store the previous value(s) for comparison to the current values.
2017 */
2018 $doCheck?(): void;
2019 /**
2020 * Called whenever one-way bindings are updated. The onChangesObj is a hash whose keys are the names of the bound
2021 * properties that have changed, and the values are an {@link IChangesObject} object of the form
2022 * { currentValue, previousValue, isFirstChange() }. Use this hook to trigger updates within a component such as
2023 * cloning the bound value to prevent accidental mutation of the outer value.
2024 */
2025 $onChanges?(onChangesObj: IOnChangesObject): void;
2026 /**
2027 * Called on a controller when its containing scope is destroyed. Use this hook for releasing external resources,
2028 * watches and event handlers.
2029 */
2030 $onDestroy?(): void;
2031 /**
2032 * Called after this controller's element and its children have been linked. Similar to the post-link function this
2033 * hook can be used to set up DOM event handlers and do direct DOM manipulation. Note that child elements that contain
2034 * templateUrl directives will not have been compiled and linked since they are waiting for their template to load
2035 * asynchronously and their own compilation and linking has been suspended until that occurs. This hook can be considered
2036 * analogous to the ngAfterViewInit and ngAfterContentInit hooks in Angular 2. Since the compilation process is rather
2037 * different in Angular 1 there is no direct mapping and care should be taken when upgrading.
2038 */
2039 $postLink?(): void;
2040
2041 // IController implementations frequently do not implement any of its methods.
2042 // A string indexer indicates to TypeScript not to issue a weak type error in this case.
2043 [s: string]: any;
2044 }
2045
2046 /**
2047 * Interface for the $onInit lifecycle hook
2048 * https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
2049 */
2050 interface IOnInit {
2051 /**
2052 * Called on each controller after all the controllers on an element have been constructed and had their bindings
2053 * initialized (and before the pre & post linking functions for the directives on this element). This is a good
2054 * place to put initialization code for your controller.
2055 */
2056 $onInit(): void;
2057 }
2058
2059 /**
2060 * Interface for the $doCheck lifecycle hook
2061 * https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
2062 */
2063 interface IDoCheck {
2064 /**
2065 * Called on each turn of the digest cycle. Provides an opportunity to detect and act on changes.
2066 * Any actions that you wish to take in response to the changes that you detect must be invoked from this hook;
2067 * implementing this has no effect on when `$onChanges` is called. For example, this hook could be useful if you wish
2068 * to perform a deep equality check, or to check a `Dat`e object, changes to which would not be detected by Angular's
2069 * change detector and thus not trigger `$onChanges`. This hook is invoked with no arguments; if detecting changes,
2070 * you must store the previous value(s) for comparison to the current values.
2071 */
2072 $doCheck(): void;
2073 }
2074
2075 /**
2076 * Interface for the $onChanges lifecycle hook
2077 * https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
2078 */
2079 interface IOnChanges {
2080 /**
2081 * Called whenever one-way bindings are updated. The onChangesObj is a hash whose keys are the names of the bound
2082 * properties that have changed, and the values are an {@link IChangesObject} object of the form
2083 * { currentValue, previousValue, isFirstChange() }. Use this hook to trigger updates within a component such as
2084 * cloning the bound value to prevent accidental mutation of the outer value.
2085 */
2086 $onChanges(onChangesObj: IOnChangesObject): void;
2087 }
2088
2089 /**
2090 * Interface for the $onDestroy lifecycle hook
2091 * https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
2092 */
2093 interface IOnDestroy {
2094 /**
2095 * Called on a controller when its containing scope is destroyed. Use this hook for releasing external resources,
2096 * watches and event handlers.
2097 */
2098 $onDestroy(): void;
2099 }
2100
2101 /**
2102 * Interface for the $postLink lifecycle hook
2103 * https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
2104 */
2105 interface IPostLink {
2106 /**
2107 * Called after this controller's element and its children have been linked. Similar to the post-link function this
2108 * hook can be used to set up DOM event handlers and do direct DOM manipulation. Note that child elements that contain
2109 * templateUrl directives will not have been compiled and linked since they are waiting for their template to load
2110 * asynchronously and their own compilation and linking has been suspended until that occurs. This hook can be considered
2111 * analogous to the ngAfterViewInit and ngAfterContentInit hooks in Angular 2. Since the compilation process is rather
2112 * different in Angular 1 there is no direct mapping and care should be taken when upgrading.
2113 */
2114 $postLink(): void;
2115 }
2116
2117 interface IOnChangesObject {
2118 [property: string]: IChangesObject<any>;
2119 }
2120
2121 interface IChangesObject<T> {
2122 currentValue: T;
2123 previousValue: T;
2124 isFirstChange(): boolean;
2125 }
2126
2127 ///////////////////////////////////////////////////////////////////////////
2128 // Directive
2129 // see http://docs.angularjs.org/api/ng/provider/$compileProvider#directive
2130 // and http://docs.angularjs.org/guide/directive
2131 ///////////////////////////////////////////////////////////////////////////
2132
2133 type IDirectiveController = IController | IController[] | {[key: string]: IController};
2134
2135 interface IDirectiveFactory<TScope extends IScope = IScope, TElement extends JQLite = JQLite, TAttributes extends IAttributes = IAttributes, TController extends IDirectiveController = IController> {
2136 (...args: any[]): IDirective<TScope, TElement, TAttributes, TController> | IDirectiveLinkFn<TScope, TElement, TAttributes, TController>;
2137 }
2138
2139 interface IDirectiveLinkFn<TScope extends IScope = IScope, TElement extends JQLite = JQLite, TAttributes extends IAttributes = IAttributes, TController extends IDirectiveController = IController> {
2140 (
2141 scope: TScope,
2142 instanceElement: TElement,
2143 instanceAttributes: TAttributes,
2144 controller?: TController,
2145 transclude?: ITranscludeFunction
2146 ): void;
2147 }
2148
2149 interface IDirectivePrePost<TScope extends IScope = IScope, TElement extends JQLite = JQLite, TAttributes extends IAttributes = IAttributes, TController extends IDirectiveController = IController> {
2150 pre?: IDirectiveLinkFn<TScope, TElement, TAttributes, TController> | undefined;
2151 post?: IDirectiveLinkFn<TScope, TElement, TAttributes, TController> | undefined;
2152 }
2153
2154 interface IDirectiveCompileFn<TScope extends IScope = IScope, TElement extends JQLite = JQLite, TAttributes extends IAttributes = IAttributes, TController extends IDirectiveController = IController> {
2155 (
2156 templateElement: TElement,
2157 templateAttributes: TAttributes,
2158 /**
2159 * @deprecated
2160 * Note: The transclude function that is passed to the compile function is deprecated,
2161 * as it e.g. does not know about the right outer scope. Please use the transclude function
2162 * that is passed to the link function instead.
2163 */
2164 transclude: ITranscludeFunction
2165 ): void | IDirectiveLinkFn<TScope, TElement, TAttributes, TController> | IDirectivePrePost<TScope, TElement, TAttributes, TController>;
2166 }
2167
2168 interface IDirective<TScope extends IScope = IScope, TElement extends JQLite = JQLite, TAttributes extends IAttributes = IAttributes, TController extends IDirectiveController = IController> {
2169 compile?: IDirectiveCompileFn<TScope, TElement, TAttributes, TController> | undefined;
2170 controller?: string | Injectable<IControllerConstructor> | undefined;
2171 controllerAs?: string | undefined;
2172 /**
2173 * Deprecation warning: although bindings for non-ES6 class controllers are currently bound to this before
2174 * the controller constructor is called, this use is now deprecated. Please place initialization code that
2175 * relies upon bindings inside a $onInit method on the controller, instead.
2176 */
2177 bindToController?: boolean | {[boundProperty: string]: string} | undefined;
2178 link?: IDirectiveLinkFn<TScope, TElement, TAttributes, TController> | IDirectivePrePost<TScope, TElement, TAttributes, TController> | undefined;
2179 multiElement?: boolean | undefined;
2180 priority?: number | undefined;
2181 /**
2182 * @deprecated
2183 */
2184 replace?: boolean | undefined;
2185 require?: string | string[] | {[controller: string]: string} | undefined;
2186 restrict?: string | undefined;
2187 scope?: boolean | {[boundProperty: string]: string} | undefined;
2188 template?: string | ((tElement: TElement, tAttrs: TAttributes) => string) | undefined;
2189 templateNamespace?: string | undefined;
2190 templateUrl?: string | ((tElement: TElement, tAttrs: TAttributes) => string) | undefined;
2191 terminal?: boolean | undefined;
2192 transclude?: boolean | 'element' | {[slot: string]: string} | undefined;
2193 }
2194
2195 /**
2196 * These interfaces are kept for compatibility with older versions of these type definitions.
2197 * Actually, Angular doesn't create a special subclass of jQuery objects. It extends jQuery.prototype
2198 * like jQuery plugins do, that's why all jQuery objects have these Angular-specific methods, not
2199 * only those returned from angular.element.
2200 * See: http://docs.angularjs.org/api/angular.element
2201 */
2202 interface IAugmentedJQueryStatic extends JQueryStatic {}
2203 interface IAugmentedJQuery extends JQLite {}
2204
2205 /**
2206 * Same as IController. Keeping it for compatibility with older versions of these type definitions.
2207 */
2208 interface IComponentController extends IController {}
2209
2210 ///////////////////////////////////////////////////////////////////////////
2211 // AUTO module (angular.js)
2212 ///////////////////////////////////////////////////////////////////////////
2213 namespace auto {
2214 ///////////////////////////////////////////////////////////////////////
2215 // InjectorService
2216 // see http://docs.angularjs.org/api/AUTO.$injector
2217 ///////////////////////////////////////////////////////////////////////
2218 interface IInjectorService {
2219 annotate(fn: Function, strictDi?: boolean): string[];
2220 annotate(inlineAnnotatedFunction: any[]): string[];
2221 get<T>(name: string, caller?: string): T;
2222 get(name: '$anchorScroll'): IAnchorScrollService;
2223 get(name: '$cacheFactory'): ICacheFactoryService;
2224 get(name: '$compile'): ICompileService;
2225 get(name: '$controller'): IControllerService;
2226 get(name: '$document'): IDocumentService;
2227 get(name: '$exceptionHandler'): IExceptionHandlerService;
2228 get(name: '$filter'): IFilterService;
2229 get(name: '$http'): IHttpService;
2230 get(name: '$httpBackend'): IHttpBackendService;
2231 get(name: '$httpParamSerializer'): IHttpParamSerializer;
2232 get(name: '$httpParamSerializerJQLike'): IHttpParamSerializer;
2233 get(name: '$interpolate'): IInterpolateService;
2234 get(name: '$interval'): IIntervalService;
2235 get(name: '$locale'): ILocaleService;
2236 get(name: '$location'): ILocationService;
2237 get(name: '$log'): ILogService;
2238 get(name: '$parse'): IParseService;
2239 get(name: '$q'): IQService;
2240 get(name: '$rootElement'): IRootElementService;
2241 get(name: '$rootScope'): IRootScopeService;
2242 get(name: '$sce'): ISCEService;
2243 get(name: '$sceDelegate'): ISCEDelegateService;
2244 get(name: '$templateCache'): ITemplateCacheService;
2245 get(name: '$templateRequest'): ITemplateRequestService;
2246 get(name: '$timeout'): ITimeoutService;
2247 get(name: '$window'): IWindowService;
2248 get<T>(name: '$xhrFactory'): IXhrFactory<T>;
2249 has(name: string): boolean;
2250 instantiate<T>(typeConstructor: {new(...args: any[]): T}, locals?: any): T;
2251 invoke<T = any>(func: Injectable<Function | ((...args: any[]) => T)>, context?: any, locals?: any): T;
2252 /**
2253 * Add the specified modules to the current injector.
2254 * 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.
2255 * @param modules A module, module name or annotated injection function.
2256 */
2257 loadNewModules(modules: Array<IModule|string|Injectable<(...args: any[]) => void>>): void;
2258 /** An object map of all the modules that have been loaded into the injector. */
2259 modules: {[moduleName: string]: IModule};
2260 strictDi: boolean;
2261 }
2262
2263 ///////////////////////////////////////////////////////////////////////
2264 // ProvideService
2265 // see http://docs.angularjs.org/api/AUTO.$provide
2266 ///////////////////////////////////////////////////////////////////////
2267 interface IProvideService {
2268 // Documentation says it returns the registered instance, but actual
2269 // implementation does not return anything.
2270 // constant(name: string, value: any): any;
2271 /**
2272 * 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.
2273 *
2274 * @param name The name of the constant.
2275 * @param value The constant value.
2276 */
2277 constant(name: string, value: any): void;
2278
2279 /**
2280 * 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.
2281 *
2282 * @param name The name of the service to decorate.
2283 * @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:
2284 *
2285 * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
2286 */
2287 decorator(name: string, decorator: Function): void;
2288 /**
2289 * 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.
2290 *
2291 * @param name The name of the service to decorate.
2292 * @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:
2293 *
2294 * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
2295 */
2296 decorator(name: string, inlineAnnotatedFunction: any[]): void;
2297 factory(name: string, serviceFactoryFunction: Function): IServiceProvider;
2298 factory(name: string, inlineAnnotatedFunction: any[]): IServiceProvider;
2299 provider(name: string, provider: IServiceProvider): IServiceProvider;
2300 provider(name: string, serviceProviderConstructor: Function): IServiceProvider;
2301 service(name: string, constructor: Function): IServiceProvider;
2302 service(name: string, inlineAnnotatedFunction: any[]): IServiceProvider;
2303 value(name: string, value: any): IServiceProvider;
2304 }
2305 }
2306
2307 /**
2308 * $http params serializer that converts objects to strings
2309 * see https://docs.angularjs.org/api/ng/service/$httpParamSerializer
2310 */
2311 interface IHttpParamSerializer {
2312 (obj: Object): string;
2313 }
2314
2315 interface IFilterFunction extends Function {
2316 /**
2317 * 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.**
2318 * See https://docs.angularjs.org/guide/filter#stateful-filters
2319 */
2320 $stateful?: boolean | undefined;
2321 }
2322 type FilterFactory = (...I: any[]) => IFilterFunction;
2323}
2324
\No newline at end of file