Closed RichLinnell closed 8 years ago
The target
parameter refers to (official documentation cited below):
Either the constructor function of the class for a static member, or the prototype of the class for an instance member.
So for the sake of providing a more self-descriptive code, annotating the target
parameter as a Function
type (please note the typo in your example) is correct (ultimately the decorator will target a function, which is what a class is in the form of its constructor in ES5). Anyways, annotating the parameter as Object
will ensure your function works well in any scenario. The official documentation actually recommends using any
.
Should the LogOutput decorator signature be
function LogOutput(target: Object, key: string, descriptor: any)
instead offunction LogOutput(target: Funciton, key: string, descriptor: any)
if I use the latter then I get compiler warnings in its usage.