Is it possible to create a higher order function (HOF) that modifies or adds a property to the prototype of a given class?
interface IStore {
new (): {};
}
interface IWatchable {
new() : {
watch: boolean;
};
}
const Store = <T extends IStore>(clazz: T): T & IWatchable => {
return class extends clazz {
watch = true;
};
};
class X extends Store(class {})
// ^^^^^^^^^^^^^^
// All base constructors must have the same return type.