I'm trying to add new property to class using decorator. Here is my code
function classDecorator<T extends {new(...args: any[]): {}}>(constructor: T) {
constructor.prototype.newProperty = 'some value';
}
@classDecorator
class MyClass {
property1: string = 'value1';
property2: string = 'value1';
}
const obj = new MyClass();
console.log(obj);
console.log(obj.property1);
console.log(obj.property2);
console.log(obj.newProperty); // error TS2551: Property 'newProperty' does not exist on type 'MyClass'
Is there any way to make angular to understand that MyClass also have newProperty ? Can I do it with .d.ts file?