这是装饰器功能:
const func = className => {
let instance = new className();
extendObservable(instance, instance.observables);
return instance;
};
export default func;
这是班级:
@func
class testClass {
observables = {
name: "",
fname: "",
age: 0,
};
.
.
.
.
someMethod() {
let a = this.name // <<<<< I'm getting property name does
// not exist on type testClass
}
}
如何在不复制所有可观察量的情况下删除此错误&#39;像这样的类的属性:
name: string
fname: string
age: number
observables = {
name: "",
fname: "",
age: 0,
};