As LayerModel doesn't inherit from DiagramModel, a class inheriting from NodeModel cannot correctly define its parent type to be a NodeLayerModel (due to the G extends NodeModelGenerics constraint), which is what the parent will actually be at runtime, if the node has been added to a layer.
The type the parent of a NodeModel must be a DiagramModel (which is a CanvasModel):
https://github.com/projectstorm/react-diagrams/blob/a457385a8ce3379e4554f1ba3bf866265b8b0258/packages/react-diagrams-core/src/entities/node/NodeModel.ts#L21
However, when adding a node to a layer, the layer sets the node's parent to itself:
https://github.com/projectstorm/react-diagrams/blob/a457385a8ce3379e4554f1ba3bf866265b8b0258/packages/react-canvas-core/src/entities/layer/LayerModel.ts#L79
As LayerModel doesn't inherit from DiagramModel, a class inheriting from NodeModel cannot correctly define its parent type to be a NodeLayerModel (due to the
G extends NodeModelGenerics
constraint), which is what theparent
will actually be at runtime, if the node has been added to a layer.The above also applies for links.