Apply this annotation to a given target.
Apply this annotation instance to the given constructor parameter.
Apply this annotation instance to the given method.
Apply this annotation instance to the given method parameter.
Apply this annotation instance to the given property.
Clone this annotation instance into a new one. This is not a deep copy.
Construct a decorator suitable for attaching annotations of the called type onto classes, constructor parameters, methods, properties, and parameters. Must be called while referencing the subclass of Annotation you wish to construct the decorator for. E.g., for FooAnnotation, call FooAnnotation.decorator().
The Annotation subclass for which the decorator is being constructed
Allows for specifying options which will modify the behavior of the decorator. See the DecoratorOptions documentation for more information.
Filter the given list of annotations for the ones which match this annotation class based on matching $metadataName.
Get all instances of this annotation class attached to the given class. If called on a subclass of Annotation, it returns only annotations that match that subclass.
The class to check
Get all instances of this annotation class attached to the parameters of the constructor for the given class. If called on a subclass of Annotation, it returns only annotations that match that subclass.
The class where constructor parameter annotations should be checked for
Get all instances of this annotation class attached to the given method. If called on a subclass of Annotation, it returns only annotations that match that subclass.
The class where the method is defined
The name of the method to check
Get all instances of this annotation class attached to the parameters of the given method. If called on a subclass of Annotation, it returns only annotations that match that subclass.
The class where the method is defined
The name of the method where parameter annotations should be checked for
Get all instances of this annotation class attached to the given property. If called on a subclass of Annotation, it returns only annotations that match that subclass.
The class where the property is defined
The name of the property to check
Get a single instance of this annotation class attached to the given class. If called on a subclass of Annotation, it returns only annotations that match that subclass.
Get one instance of this annotation class attached to the given method. If called on a subclass of Annotation, it returns only annotations that match that subclass.
The class where the method is defined
The name of the method to check
Get one instance of this annotation class attached to the given property. If called on a subclass of Annotation, it returns only annotations that match that subclass.
The class where the property is defined
The name of the property to check
Generated using TypeDoc
Represents a metadata annotation which can be applied to classes, constructor parameters, methods, properties, or method parameters via decorators.
Custom annotations are defined as subclasses of this class. By convention, all custom annotation classes should have a name which ends in "Annotation" such as "NameAnnotation".
To create a new annotation create a subclass of
Annotation
with a constructor that takes the parameters you are interested in storing, and save the appropriate information onto fields of the new instance. For your convenience, Annotation provides a default constructor which takes a map object and applies its properties onto the current instance, but you may replace it with a constructor that takes any arguments you wish.You may wish to add type safety to the default constructor parameter. To do so, override the constructor and define it:
class XYZ extends Annotation { constructor( options : MyOptions ) { super(options); } }
Annotations are applied by using decorators. When you define a custom annotation, you must also define a custom decorator:
const Name = NameAnnotation.decorator();
You can then use that decorator:
@Name() class ABC { // ... }