我正在尝试使用装饰器向类添加新属性。这是我的代码
LOAD DATA INFILE 'gs://Bucket_name/pre.txt' INTO TABLE Prep FIELDS TERMINATED BY '\t' LInes TERMINATED BY '\r\n' IGNORE 1 LInes;
有什么方法可以使您了解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'
也有MyClass
吗?我可以使用newProperty
文件吗?