I have a set of unique class decorators that I apply to multiple classes. It looks something like this:
@awesome
@cool
@amazing
export class MySpecialClass { /* ..... */ }
However, since I use these three decorators across many classes, I want to condense them into one decorator like this:
@super
export class MySpecialClass { /* ... */ }
I attempted to create a new decorator that chains the calls like so:
export function super<ReturnType>(ctor: Constructor<ReturnType>) {
return amazing(cool(awesome(ctor)));
}
According to the TypeScript documentation, applying multiple decorators should work similarly to function composition, which is why I thought chaining them would be possible. But when compiling (using TypeScript 1.8), I encountered an error message like this:
Unable to resolve signature of class decorator when called as an expression. Type 'Constructor<ReturnType>' is not assignable to type 'void'.
Is there a way for me to create this 'wrapper' decorator to streamline my code?