我有一个对象,该对象具有我想从其他类型扩展的属性,例如:
interface FabricObjectWithId extends fabric.Object {
id: string
}
接口INeedPropsOfThisObj没有id,所以在MyObj接口上,我想添加id属性,但是出现错误。帮助吗?
这是我的用例:
private getObjectOnCanvasById = (id: string) =>
this.handler.canvas
.getObjects()
.find((obj: FabricObjectWithId) => obj.id === id);
错误消息:
Types of parameters 'obj' and 'value' are incompatible.
Type 'Object' is not assignable to type 'FabricObjectWithId'.