import { Reflect } from "https://deno.land/x/alosaur@v0.21.0/src/injection/reflect.ts";
const { defineMetadata } = Reflect;
Define a unique metadata entry on the target.
Examples
class Example {
}
class Example { }
// constructor Reflect.defineMetadata("custom:annotation", options, Example);
// decorator factory as metadata-producing annotation.
function MyAnnotation(options): ClassDecorator {
return target => Reflect.defineMetadata("custom:annotation", options, target);
}
Define a unique metadata entry on the target.
Examples
class Example {
// property declarations are not part of ES6, though they are valid in TypeScript:
// static staticProperty;
// property;
class Example { // property declarations are not part of ES6, though they are valid in TypeScript: // static staticProperty; // property;
static staticMethod(p) { } method(p) { } }
// property (on constructor)
Reflect.defineMetadata("custom:annotation", Number, Example, "staticProperty");
// property (on prototype)
Reflect.defineMetadata("custom:annotation", Number, Example.prototype, "property");
// method (on constructor)
Reflect.defineMetadata("custom:annotation", Number, Example, "staticMethod");
// method (on prototype)
Reflect.defineMetadata("custom:annotation", Number, Example.prototype, "method");
// decorator factory as metadata-producing annotation.
function MyAnnotation(options): PropertyDecorator {
return (target, key) => Reflect.defineMetadata("custom:annotation", options, target, key);
}