fix: typesafety of Node and Edge changes
On some functions and type definitions related to Change Events,
the generics for the types Node and Edge were being lost.
This commit fixes those:
- Functions
- applyNodeChanges
- applyEdgeChanges
- Types
- NodeChange
- EdgeChange
- OnNodesChange
- OnEdgesChange
This commit is contained in:
@@ -188,7 +188,10 @@ function applyChange(change: any, element: any, elements: any[] = []): any {
|
||||
<ReactFLow nodes={nodes} edges={edges} onNodesChange={onNodesChange} />
|
||||
);
|
||||
*/
|
||||
export function applyNodeChanges<NodeType extends Node = Node>(changes: NodeChange[], nodes: NodeType[]): NodeType[] {
|
||||
export function applyNodeChanges<NodeType extends Node = Node>(
|
||||
changes: NodeChange<NodeType>[],
|
||||
nodes: NodeType[]
|
||||
): NodeType[] {
|
||||
return applyChanges(changes, nodes) as NodeType[];
|
||||
}
|
||||
|
||||
@@ -212,7 +215,10 @@ export function applyNodeChanges<NodeType extends Node = Node>(changes: NodeChan
|
||||
<ReactFlow nodes={nodes} edges={edges} onEdgesChange={onEdgesChange} />
|
||||
);
|
||||
*/
|
||||
export function applyEdgeChanges<EdgeType extends Edge = Edge>(changes: EdgeChange[], edges: EdgeType[]): EdgeType[] {
|
||||
export function applyEdgeChanges<EdgeType extends Edge = Edge>(
|
||||
changes: EdgeChange<EdgeType>[],
|
||||
edges: EdgeType[]
|
||||
): EdgeType[] {
|
||||
return applyChanges(changes, edges) as EdgeType[];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user