Closed SebGo closed 4 years ago
I agree with @SebGo I have the same isse, the shape constructor is expected by the registerShape
function.
When I used the old https://github.com/lgleim/mxgraph-typings, I can do mxCellRenderer.registerShape("MyShape", MyShape);
and this perfectly works at runtime.
For a real example using lgleim
types, see https://github.com/process-analytics/bpmn-visualization-js/blob/v0.1.5/src/component/mxgraph/ShapeConfigurator.ts#L37
@hungtcs I am preparing a Pull Request for this.
About the constructor parameters types, I will use ...args: any
as suggested in the issue.
mxGraph standard shapes use bounds: mxRectangle, fill: string, stroke: string, strokewidth: number
. I guess that as mxGraph is in charge of instantiating the mxShape, subclassers cannot add extra parameters, but I don't want to introduce any limitations or integration issues for now. We can manage stricter types later
[UPDATE]: mxShape constructor is constructor(stencil: mxStencil)
, wich highly suggests to keep ...args: any
in the registerShape
signature
Thanks for your solution @SebGo , I have encountered the same problem these days, but I didn't find the perfect way.
Hi,
Thank you for the work you do in this repo.
I'm trying to implement a custom shape by extending mxActor.
When registering the Shape I get following error:
Argument of type 'typeof MyShape' is not assignable to parameter of type 'typeof mxShape'.
I think a solution could be to change registerShape() in mxCellRenderer.d.ts from
static registerShape(key: string, shape: typeof mxShape): void;
tostatic registerShape(key: string, shape: new (...args: any) => mxShape): void;