可能我在这里遗漏了一些明显的东西,但为什么这不起作用?
this.props.entity
绝对是 GraphData 类型,并且 delta 中的属性在 GraphData 上有效。
const newEntity: GraphData = {...this.props.entity, ...delta } as GraphData;
if(newEntity instanceof GraphData) {
console.log('Yay');
}
即使这样也行不通
const newEntity: GraphData = {...this.props.entity } as GraphData;
if(newEntity instanceof GraphData) {
console.log('Yay');
}
newEntity 始终是 Object 类型