流量获取错误Cannot assign
值to
this [key] because an index signature declaring the expected key / value type is missing in
Dict [1].
这样可以实现这样的代码吗?
class Dict {
constructor(props: Object) {
Object.entries(props).forEach(([key, value]) => {
this[key] = value;
});
}
}
class Int extends Dict {
value: number;
constructor({ value }) {
super({ name: 'int', value });
}
}
const int = new Int({ value: 1 });
const type: number = int.value;