The constructor function or function that the decorators will be applied to.
A decorator or array of decorators to apply to the type or function.
A map of decorators to be applied to the properties of a type. The key is the name of the property and the value is a decorator or an array of decorators.
Suppose you have a decorator, Entity, that marks a class as a persistent entity. We can apply the decorator to our type as follows:
function Person(name) {
this.name = name;
}
decorate(Person, Entity());
An array of decorators can be applied to a type:
decorate(Person, [Entity(), Collection("people")]);
Suppose we have a decorator factory, Type, that gives the type of a field for a persistent entity. We can apply the decorator to a property of our type as follows:
function Person(name) {
this.name = name;
}
decorate(Person, Entity(), {
name: Type(String)
});
An array of decorators can be applied for a property:
decorate(Person, Entity(), {
name: [Type(String), Field("n")]
});
Gets type metadata for the specified concrete type.
The concrete type.
Makes a decorator factory from an annotation. The resulting decorator factory can be applied to a class or property.
The annotation constructor.
An annotation is just a class. So, supposed with have an annotation that marks a class as a persistent entity as follows:
class EntityAnnotation {
constructor(public name?: string) {
}
}
We can turn that annotation into a class decorator. When applied, an instance of the annotation is created and added to the 'annotations' metadata for the class. The parameters for the decorator will be the same as the parameters for the class constructor. However, we may want to provide a type annotation for the decorator factory because the parameters cannot be inferred.
var Entity: (name?: string) => ClassDecorator = makeDecorator(EntityAnnotation);
The Entity decorator can be applied as follows:
@Entity()
class Person {
}
Generated using TypeDoc
A helper function to apply decorators in ES5.