Skip to content

Commit 4b20ca0

Browse files
committed
refactor(core): GraphNode, GraphEdge as generic for findNode, findEdge actions
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
1 parent c95c229 commit 4b20ca0

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

packages/core/src/types/store.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { CSSProperties, ComputedRef, ToRefs } from 'vue'
22
import type { KeyFilter } from '@vueuse/core'
33
import type {
44
Dimensions,
5-
ElementData,
65
Elements,
76
FlowElements,
87
FlowExportObject,
@@ -25,7 +24,7 @@ import type {
2524
import type { DefaultEdgeOptions, Edge, EdgeUpdatable, GraphEdge } from './edge'
2625
import type { CoordinateExtent, GraphNode, Node } from './node'
2726
import type { D3Selection, D3Zoom, D3ZoomHandler, PanOnScrollMode, ViewportFunctions, ViewportTransform } from './zoom'
28-
import type { CustomEvent, FlowHooks, FlowHooksEmit, FlowHooksOn } from './hooks'
27+
import type { FlowHooks, FlowHooksEmit, FlowHooksOn } from './hooks'
2928
import type { EdgeChange, NodeChange, NodeDragItem } from './changes'
3029
import type { StartHandle, ValidConnectionFunc, ValidHandleResult } from './handle'
3130

@@ -177,13 +176,9 @@ export type UpdateNodeDimensions = (updates: UpdateNodeDimensionsParams[]) => vo
177176

178177
export type UpdateNodeInternals = (nodeIds?: string[]) => void
179178

180-
export type FindNode = <Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>(
181-
id: string,
182-
) => GraphNode<Data, CustomEvents> | undefined
179+
export type FindNode = <T extends GraphNode = GraphNode>(id: string) => T | undefined
183180

184-
export type FindEdge = <Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>(
185-
id: string,
186-
) => GraphEdge<Data, CustomEvents> | undefined
181+
export type FindEdge = <T extends GraphEdge = GraphEdge>(id: string) => T | undefined
187182

188183
export type GetIntersectingNodes = (
189184
node: (Partial<Node> & { id: Node['id'] }) | Rect,

0 commit comments

Comments
 (0)