index.d.ts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. // Generated by typings
  2. // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/9cfb866c9f912174c8c6d15a2dc24399cfd71f37/reflect-metadata/reflect-metadata.d.ts
  3. declare module "reflect-metadata" {
  4. // The "reflect-metadata" module has no imports or exports, but can be used by modules to load the polyfill.
  5. }
  6. declare namespace Reflect {
  7. /**
  8. * Applies a set of decorators to a target object.
  9. * @param decorators An array of decorators.
  10. * @param target The target object.
  11. * @returns The result of applying the provided decorators.
  12. * @remarks Decorators are applied in reverse order of their positions in the array.
  13. * @example
  14. *
  15. * class C { }
  16. *
  17. * // constructor
  18. * C = Reflect.decorate(decoratorsArray, C);
  19. *
  20. */
  21. function decorate(decorators: ClassDecorator[], target: Function): Function;
  22. /**
  23. * Applies a set of decorators to a property of a target object.
  24. * @param decorators An array of decorators.
  25. * @param target The target object.
  26. * @param targetKey The property key to decorate.
  27. * @param descriptor A property descriptor
  28. * @remarks Decorators are applied in reverse order.
  29. * @example
  30. *
  31. * class C {
  32. * // property declarations are not part of ES6, though they are valid in TypeScript:
  33. * // static staticProperty;
  34. * // property;
  35. *
  36. * static staticMethod() { }
  37. * method() { }
  38. * }
  39. *
  40. * // property (on constructor)
  41. * Reflect.decorate(decoratorsArray, C, "staticProperty");
  42. *
  43. * // property (on prototype)
  44. * Reflect.decorate(decoratorsArray, C.prototype, "property");
  45. *
  46. * // method (on constructor)
  47. * Object.defineProperty(C, "staticMethod",
  48. * Reflect.decorate(decoratorsArray, C, "staticMethod",
  49. * Object.getOwnPropertyDescriptor(C, "staticMethod")));
  50. *
  51. * // method (on prototype)
  52. * Object.defineProperty(C.prototype, "method",
  53. * Reflect.decorate(decoratorsArray, C.prototype, "method",
  54. * Object.getOwnPropertyDescriptor(C.prototype, "method")));
  55. *
  56. */
  57. function decorate(decorators: (PropertyDecorator | MethodDecorator)[], target: Object, targetKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor;
  58. /**
  59. * A default metadata decorator factory that can be used on a class, class member, or parameter.
  60. * @param metadataKey The key for the metadata entry.
  61. * @param metadataValue The value for the metadata entry.
  62. * @returns A decorator function.
  63. * @remarks
  64. * If `metadataKey` is already defined for the target and target key, the
  65. * metadataValue for that key will be overwritten.
  66. * @example
  67. *
  68. * // constructor
  69. * @Reflect.metadata(key, value)
  70. * class C {
  71. * }
  72. *
  73. * // property (on constructor, TypeScript only)
  74. * class C {
  75. * @Reflect.metadata(key, value)
  76. * static staticProperty;
  77. * }
  78. *
  79. * // property (on prototype, TypeScript only)
  80. * class C {
  81. * @Reflect.metadata(key, value)
  82. * property;
  83. * }
  84. *
  85. * // method (on constructor)
  86. * class C {
  87. * @Reflect.metadata(key, value)
  88. * static staticMethod() { }
  89. * }
  90. *
  91. * // method (on prototype)
  92. * class C {
  93. * @Reflect.metadata(key, value)
  94. * method() { }
  95. * }
  96. *
  97. */
  98. function metadata(metadataKey: any, metadataValue: any): {
  99. (target: Function): void;
  100. (target: Object, propertyKey: string | symbol): void;
  101. };
  102. /**
  103. * Define a unique metadata entry on the target.
  104. * @param metadataKey A key used to store and retrieve metadata.
  105. * @param metadataValue A value that contains attached metadata.
  106. * @param target The target object on which to define metadata.
  107. * @example
  108. *
  109. * class C {
  110. * }
  111. *
  112. * // constructor
  113. * Reflect.defineMetadata("custom:annotation", options, C);
  114. *
  115. * // decorator factory as metadata-producing annotation.
  116. * function MyAnnotation(options): ClassDecorator {
  117. * return target => Reflect.defineMetadata("custom:annotation", options, target);
  118. * }
  119. *
  120. */
  121. function defineMetadata(metadataKey: any, metadataValue: any, target: Object): void;
  122. /**
  123. * Define a unique metadata entry on the target.
  124. * @param metadataKey A key used to store and retrieve metadata.
  125. * @param metadataValue A value that contains attached metadata.
  126. * @param target The target object on which to define metadata.
  127. * @param targetKey The property key for the target.
  128. * @example
  129. *
  130. * class C {
  131. * // property declarations are not part of ES6, though they are valid in TypeScript:
  132. * // static staticProperty;
  133. * // property;
  134. *
  135. * static staticMethod(p) { }
  136. * method(p) { }
  137. * }
  138. *
  139. * // property (on constructor)
  140. * Reflect.defineMetadata("custom:annotation", Number, C, "staticProperty");
  141. *
  142. * // property (on prototype)
  143. * Reflect.defineMetadata("custom:annotation", Number, C.prototype, "property");
  144. *
  145. * // method (on constructor)
  146. * Reflect.defineMetadata("custom:annotation", Number, C, "staticMethod");
  147. *
  148. * // method (on prototype)
  149. * Reflect.defineMetadata("custom:annotation", Number, C.prototype, "method");
  150. *
  151. * // decorator factory as metadata-producing annotation.
  152. * function MyAnnotation(options): PropertyDecorator {
  153. * return (target, key) => Reflect.defineMetadata("custom:annotation", options, target, key);
  154. * }
  155. *
  156. */
  157. function defineMetadata(metadataKey: any, metadataValue: any, target: Object, targetKey: string | symbol): void;
  158. /**
  159. * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
  160. * @param metadataKey A key used to store and retrieve metadata.
  161. * @param target The target object on which the metadata is defined.
  162. * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
  163. * @example
  164. *
  165. * class C {
  166. * }
  167. *
  168. * // constructor
  169. * result = Reflect.hasMetadata("custom:annotation", C);
  170. *
  171. */
  172. function hasMetadata(metadataKey: any, target: Object): boolean;
  173. /**
  174. * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
  175. * @param metadataKey A key used to store and retrieve metadata.
  176. * @param target The target object on which the metadata is defined.
  177. * @param targetKey The property key for the target.
  178. * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
  179. * @example
  180. *
  181. * class C {
  182. * // property declarations are not part of ES6, though they are valid in TypeScript:
  183. * // static staticProperty;
  184. * // property;
  185. *
  186. * static staticMethod(p) { }
  187. * method(p) { }
  188. * }
  189. *
  190. * // property (on constructor)
  191. * result = Reflect.hasMetadata("custom:annotation", C, "staticProperty");
  192. *
  193. * // property (on prototype)
  194. * result = Reflect.hasMetadata("custom:annotation", C.prototype, "property");
  195. *
  196. * // method (on constructor)
  197. * result = Reflect.hasMetadata("custom:annotation", C, "staticMethod");
  198. *
  199. * // method (on prototype)
  200. * result = Reflect.hasMetadata("custom:annotation", C.prototype, "method");
  201. *
  202. */
  203. function hasMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean;
  204. /**
  205. * Gets a value indicating whether the target object has the provided metadata key defined.
  206. * @param metadataKey A key used to store and retrieve metadata.
  207. * @param target The target object on which the metadata is defined.
  208. * @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
  209. * @example
  210. *
  211. * class C {
  212. * }
  213. *
  214. * // constructor
  215. * result = Reflect.hasOwnMetadata("custom:annotation", C);
  216. *
  217. */
  218. function hasOwnMetadata(metadataKey: any, target: Object): boolean;
  219. /**
  220. * Gets a value indicating whether the target object has the provided metadata key defined.
  221. * @param metadataKey A key used to store and retrieve metadata.
  222. * @param target The target object on which the metadata is defined.
  223. * @param targetKey The property key for the target.
  224. * @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
  225. * @example
  226. *
  227. * class C {
  228. * // property declarations are not part of ES6, though they are valid in TypeScript:
  229. * // static staticProperty;
  230. * // property;
  231. *
  232. * static staticMethod(p) { }
  233. * method(p) { }
  234. * }
  235. *
  236. * // property (on constructor)
  237. * result = Reflect.hasOwnMetadata("custom:annotation", C, "staticProperty");
  238. *
  239. * // property (on prototype)
  240. * result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "property");
  241. *
  242. * // method (on constructor)
  243. * result = Reflect.hasOwnMetadata("custom:annotation", C, "staticMethod");
  244. *
  245. * // method (on prototype)
  246. * result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "method");
  247. *
  248. */
  249. function hasOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean;
  250. /**
  251. * Gets the metadata value for the provided metadata key on the target object or its prototype chain.
  252. * @param metadataKey A key used to store and retrieve metadata.
  253. * @param target The target object on which the metadata is defined.
  254. * @returns The metadata value for the metadata key if found; otherwise, `undefined`.
  255. * @example
  256. *
  257. * class C {
  258. * }
  259. *
  260. * // constructor
  261. * result = Reflect.getMetadata("custom:annotation", C);
  262. *
  263. */
  264. function getMetadata(metadataKey: any, target: Object): any;
  265. /**
  266. * Gets the metadata value for the provided metadata key on the target object or its prototype chain.
  267. * @param metadataKey A key used to store and retrieve metadata.
  268. * @param target The target object on which the metadata is defined.
  269. * @param targetKey The property key for the target.
  270. * @returns The metadata value for the metadata key if found; otherwise, `undefined`.
  271. * @example
  272. *
  273. * class C {
  274. * // property declarations are not part of ES6, though they are valid in TypeScript:
  275. * // static staticProperty;
  276. * // property;
  277. *
  278. * static staticMethod(p) { }
  279. * method(p) { }
  280. * }
  281. *
  282. * // property (on constructor)
  283. * result = Reflect.getMetadata("custom:annotation", C, "staticProperty");
  284. *
  285. * // property (on prototype)
  286. * result = Reflect.getMetadata("custom:annotation", C.prototype, "property");
  287. *
  288. * // method (on constructor)
  289. * result = Reflect.getMetadata("custom:annotation", C, "staticMethod");
  290. *
  291. * // method (on prototype)
  292. * result = Reflect.getMetadata("custom:annotation", C.prototype, "method");
  293. *
  294. */
  295. function getMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any;
  296. /**
  297. * Gets the metadata value for the provided metadata key on the target object.
  298. * @param metadataKey A key used to store and retrieve metadata.
  299. * @param target The target object on which the metadata is defined.
  300. * @returns The metadata value for the metadata key if found; otherwise, `undefined`.
  301. * @example
  302. *
  303. * class C {
  304. * }
  305. *
  306. * // constructor
  307. * result = Reflect.getOwnMetadata("custom:annotation", C);
  308. *
  309. */
  310. function getOwnMetadata(metadataKey: any, target: Object): any;
  311. /**
  312. * Gets the metadata value for the provided metadata key on the target object.
  313. * @param metadataKey A key used to store and retrieve metadata.
  314. * @param target The target object on which the metadata is defined.
  315. * @param targetKey The property key for the target.
  316. * @returns The metadata value for the metadata key if found; otherwise, `undefined`.
  317. * @example
  318. *
  319. * class C {
  320. * // property declarations are not part of ES6, though they are valid in TypeScript:
  321. * // static staticProperty;
  322. * // property;
  323. *
  324. * static staticMethod(p) { }
  325. * method(p) { }
  326. * }
  327. *
  328. * // property (on constructor)
  329. * result = Reflect.getOwnMetadata("custom:annotation", C, "staticProperty");
  330. *
  331. * // property (on prototype)
  332. * result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "property");
  333. *
  334. * // method (on constructor)
  335. * result = Reflect.getOwnMetadata("custom:annotation", C, "staticMethod");
  336. *
  337. * // method (on prototype)
  338. * result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "method");
  339. *
  340. */
  341. function getOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any;
  342. /**
  343. * Gets the metadata keys defined on the target object or its prototype chain.
  344. * @param target The target object on which the metadata is defined.
  345. * @returns An array of unique metadata keys.
  346. * @example
  347. *
  348. * class C {
  349. * }
  350. *
  351. * // constructor
  352. * result = Reflect.getMetadataKeys(C);
  353. *
  354. */
  355. function getMetadataKeys(target: Object): any[];
  356. /**
  357. * Gets the metadata keys defined on the target object or its prototype chain.
  358. * @param target The target object on which the metadata is defined.
  359. * @param targetKey The property key for the target.
  360. * @returns An array of unique metadata keys.
  361. * @example
  362. *
  363. * class C {
  364. * // property declarations are not part of ES6, though they are valid in TypeScript:
  365. * // static staticProperty;
  366. * // property;
  367. *
  368. * static staticMethod(p) { }
  369. * method(p) { }
  370. * }
  371. *
  372. * // property (on constructor)
  373. * result = Reflect.getMetadataKeys(C, "staticProperty");
  374. *
  375. * // property (on prototype)
  376. * result = Reflect.getMetadataKeys(C.prototype, "property");
  377. *
  378. * // method (on constructor)
  379. * result = Reflect.getMetadataKeys(C, "staticMethod");
  380. *
  381. * // method (on prototype)
  382. * result = Reflect.getMetadataKeys(C.prototype, "method");
  383. *
  384. */
  385. function getMetadataKeys(target: Object, targetKey: string | symbol): any[];
  386. /**
  387. * Gets the unique metadata keys defined on the target object.
  388. * @param target The target object on which the metadata is defined.
  389. * @returns An array of unique metadata keys.
  390. * @example
  391. *
  392. * class C {
  393. * }
  394. *
  395. * // constructor
  396. * result = Reflect.getOwnMetadataKeys(C);
  397. *
  398. */
  399. function getOwnMetadataKeys(target: Object): any[];
  400. /**
  401. * Gets the unique metadata keys defined on the target object.
  402. * @param target The target object on which the metadata is defined.
  403. * @param targetKey The property key for the target.
  404. * @returns An array of unique metadata keys.
  405. * @example
  406. *
  407. * class C {
  408. * // property declarations are not part of ES6, though they are valid in TypeScript:
  409. * // static staticProperty;
  410. * // property;
  411. *
  412. * static staticMethod(p) { }
  413. * method(p) { }
  414. * }
  415. *
  416. * // property (on constructor)
  417. * result = Reflect.getOwnMetadataKeys(C, "staticProperty");
  418. *
  419. * // property (on prototype)
  420. * result = Reflect.getOwnMetadataKeys(C.prototype, "property");
  421. *
  422. * // method (on constructor)
  423. * result = Reflect.getOwnMetadataKeys(C, "staticMethod");
  424. *
  425. * // method (on prototype)
  426. * result = Reflect.getOwnMetadataKeys(C.prototype, "method");
  427. *
  428. */
  429. function getOwnMetadataKeys(target: Object, targetKey: string | symbol): any[];
  430. /**
  431. * Deletes the metadata entry from the target object with the provided key.
  432. * @param metadataKey A key used to store and retrieve metadata.
  433. * @param target The target object on which the metadata is defined.
  434. * @returns `true` if the metadata entry was found and deleted; otherwise, false.
  435. * @example
  436. *
  437. * class C {
  438. * }
  439. *
  440. * // constructor
  441. * result = Reflect.deleteMetadata("custom:annotation", C);
  442. *
  443. */
  444. function deleteMetadata(metadataKey: any, target: Object): boolean;
  445. /**
  446. * Deletes the metadata entry from the target object with the provided key.
  447. * @param metadataKey A key used to store and retrieve metadata.
  448. * @param target The target object on which the metadata is defined.
  449. * @param targetKey The property key for the target.
  450. * @returns `true` if the metadata entry was found and deleted; otherwise, false.
  451. * @example
  452. *
  453. * class C {
  454. * // property declarations are not part of ES6, though they are valid in TypeScript:
  455. * // static staticProperty;
  456. * // property;
  457. *
  458. * static staticMethod(p) { }
  459. * method(p) { }
  460. * }
  461. *
  462. * // property (on constructor)
  463. * result = Reflect.deleteMetadata("custom:annotation", C, "staticProperty");
  464. *
  465. * // property (on prototype)
  466. * result = Reflect.deleteMetadata("custom:annotation", C.prototype, "property");
  467. *
  468. * // method (on constructor)
  469. * result = Reflect.deleteMetadata("custom:annotation", C, "staticMethod");
  470. *
  471. * // method (on prototype)
  472. * result = Reflect.deleteMetadata("custom:annotation", C.prototype, "method");
  473. *
  474. */
  475. function deleteMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean;
  476. }