问题描述
public void RemoveNumber(int number) => _ = Numbers.Remove(number);
根据我的理解,TS2345: Argument of type '(bounds: any,fill: any,stroke: any,strokewidth: any) => mxShape' is not assignable to parameter of type 'new (...args: any) => mxShape'.
Type '(bounds: any,strokewidth: any) => mxShape' provides no match for the signature 'new (...args: any): mxShape'.
应该足以满足给定的需求,但 Typescript 说,它不适合它。为什么?
我的 MxHeaderShape 是这样构建的:
new (...args: any): mxShape
解决方法
您似乎想要创建一个扩展 MxHeaderFooterShape
的 mxShape
类。
假设您使用的是typed-mxgraph,您可以使用这种方式
import mx from './mxgraph'; // mxGraphExportObject returned by the mxgraph factory function
import { mxRectangle } from 'mxgraph';
class CustomMxShape extends mx.mxShape {
constructor(bounds: mxRectangle,fill: string,stroke: string,strokewidth?: number) {
super(bounds,fill,stroke,strokewidth);
}
}