angularjs.d.ts 79 KB

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