Restricting Annotation Targets
By default, custom annotations can be used in various positions such as type declarations, functions, member variables, parameters, etc. However, sometimes we want to restrict annotations to specific positions to reduce misuse. This can be achieved by specifying the target parameter when defining the annotation.
The target parameter accepts an Array<AnnotationKind> array, where AnnotationKind is an enumeration in the standard library containing values such as Type, MemberFunction, MemberProperty, Parameter, etc. When target is restricted, the annotation can only be used in the declared list of positions.
The code on the right defines a @Log annotation that can only be used on member functions, and an @Entity annotation that can only be used on types, demonstrating their correct usage.
Try applying the @Log annotation to a class definition (line 21) and see what error the compiler reports.