UNPKG

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