From cb72b6a3585bd6772350f728ed1782dc74b7e49f Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 2 Oct 2023 12:51:32 +0200 Subject: [PATCH] fix(svelte) improved type --- packages/svelte/src/lib/hooks/useSvelteFlow.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/svelte/src/lib/hooks/useSvelteFlow.ts b/packages/svelte/src/lib/hooks/useSvelteFlow.ts index ced33dba..611c6227 100644 --- a/packages/svelte/src/lib/hooks/useSvelteFlow.ts +++ b/packages/svelte/src/lib/hooks/useSvelteFlow.ts @@ -27,12 +27,12 @@ export function useSvelteFlow(): { getViewport: () => Viewport; fitView: (options?: FitViewOptions) => void; getIntersectingNodes: ( - nodeOrRect: Partial> | Rect, + nodeOrRect: (Partial> & { id: Node['id'] }) | Rect, partially?: boolean, nodesToIntersect?: Node[] ) => Node[]; isNodeIntersecting: ( - nodeOrRect: Partial> | Rect, + nodeOrRect: (Partial> & { id: Node['id'] }) | Rect, area: Rect, partially?: boolean ) => boolean; @@ -56,7 +56,7 @@ export function useSvelteFlow(): { } = useStore(); const getNodeRect = ( - nodeOrRect: Partial> | Rect + nodeOrRect: (Partial> & { id: Node['id'] }) | Rect ): [Rect | null, Node | null | undefined, boolean] => { const isRect = isRectObject(nodeOrRect); const node = isRect ? null : get(nodes).find((n) => n.id === nodeOrRect.id); @@ -108,7 +108,7 @@ export function useSvelteFlow(): { }, fitView, getIntersectingNodes: ( - nodeOrRect: Partial> | Rect, + nodeOrRect: (Partial> & { id: Node['id'] }) | Rect, partially = true, nodesToIntersect?: Node[] ) => { @@ -130,7 +130,11 @@ export function useSvelteFlow(): { return partiallyVisible || overlappingArea >= nodeOrRect.width! * nodeOrRect.height!; }); }, - isNodeIntersecting: (nodeOrRect: Partial> | Rect, area: Rect, partially = true) => { + isNodeIntersecting: ( + nodeOrRect: (Partial> & { id: Node['id'] }) | Rect, + area: Rect, + partially = true + ) => { const [nodeRect] = getNodeRect(nodeOrRect); if (!nodeRect) {