no-conflict.d.ts 18 KB

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