So i have this error:
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, fill: any, stroke: any, strokewidth: any) => mxShape' provides no match for the signature 'new (...args: any): mxShape'.
In my understanding, new (...args: any): mxShape
should be sufficient for the given, but Typescript says, its not fitting for it. Why?
This how my MxHeaderShape is built:
function MxHeaderFooterShape(bounds, fill, stroke, strokewidth) : mxShape{
let val = mxShape.call(this);
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
return val;
}
It seems that you want to create a MxHeaderFooterShape
class that extends mxShape
.
Assuming you are using typed-mxgraph, you can use this way of doing
import mx from './mxgraph'; // mxGraphExportObject returned by the mxgraph factory function
import type { mxRectangle } from 'mxgraph';
class CustomMxShape extends mx.mxShape {
constructor(bounds: mxRectangle, fill: string, stroke: string, strokewidth?: number) {
super(bounds, fill, stroke, strokewidth);
}
}
You can also check this demo: https://github.com/typed-mxgraph/typed-mxgraph-example-bundled-with-webpack/blob/7f0bf757aedb12cec84d86b4c4e4cbcb0f7a8147/src/app/custom-shapes.ts