I want to create a decorator, that would override some variables, if they need to. Something like
const Decorator = <T extends { new (...args: any[]): any }>(target: T) => {
return class extends target {
field = 1;
field2 = 2;
};
};
But for one classes there should be only field, for others only field2, and some of them should be both.
I tried it, but it doesn't work
const Decorator = <T extends { new (...args: any[]): any }>(target: T) => {
if (...) {
target.prototype.field = 1;
}
if (...) {
target.prototype.field2 = 2;
}
return class extends target {};
};