Issue
I have the following class:
export abstract class CanDeactivateComponent {
abstract canLeavePage(): boolean;
abstract onPageLeave(): void;
@someDecorator
abstract canDeactivateBeforeUnload(): boolean;
}
and I get the error A decorator can only decorate a method implementation, not an overload
. I understand I can not put a decorator in that case but, which workaround can be applied so that I force all implementations of this class to use @someDecorator
before canDeactivateBeforeUnload
? Isn't there any way to put this decorator in the abstract class itself so that I don't have to write it in all the implementations?
Thank you!
Solution
I guess it depends on the context, but perhaps using a method that proxies can work for you?
export abstract class CanDeactivateComponent {
abstract canLeavePage(): boolean;
abstract onPageLeave(): void;
abstract canDeactivateBeforeUnload(): boolean;
@someDecorator
_canDeactivateBeforeUnload(): boolean {
return this.canDeactivateBeforeUnload()
}
}
Answered By - Rengers
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.