import { Reflect } from "https://dotland.deno.dev/x/alosaur@v0.35.0/src/injection/reflect.ts";
const { decorate } = Reflect;
Applies a set of decorators to a property of a target object.
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() { } method() { } }
// property (on constructor)
Reflect.decorate(decoratorsArray, Example, "staticProperty");
// property (on prototype)
Reflect.decorate(decoratorsArray, Example.prototype, "property");
// method (on constructor)
Object.defineProperty(Example, "staticMethod",
Reflect.decorate(decoratorsArray, Example, "staticMethod",
Object.getOwnPropertyDescriptor(Example, "staticMethod")));
// method (on prototype)
Object.defineProperty(Example.prototype, "method",
Reflect.decorate(decoratorsArray, Example.prototype, "method",
Object.getOwnPropertyDescriptor(Example.prototype, "method")));
Applies a set of decorators to a property of a target object.
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() { } method() { } }
// property (on constructor)
Reflect.decorate(decoratorsArray, Example, "staticProperty");
// property (on prototype)
Reflect.decorate(decoratorsArray, Example.prototype, "property");
// method (on constructor)
Object.defineProperty(Example, "staticMethod",
Reflect.decorate(decoratorsArray, Example, "staticMethod",
Object.getOwnPropertyDescriptor(Example, "staticMethod")));
// method (on prototype)
Object.defineProperty(Example.prototype, "method",
Reflect.decorate(decoratorsArray, Example.prototype, "method",
Object.getOwnPropertyDescriptor(Example.prototype, "method")));