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