From 1184941900712877282af052c32f3fd8341f8ef7 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Fri, 23 Feb 2024 00:33:44 +0100 Subject: [PATCH] fix(core,composables): correct typing of `useNodesData` return --- packages/core/src/composables/useNodesData.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/core/src/composables/useNodesData.ts b/packages/core/src/composables/useNodesData.ts index e9afc4fb..9c1e8ca2 100644 --- a/packages/core/src/composables/useNodesData.ts +++ b/packages/core/src/composables/useNodesData.ts @@ -4,7 +4,11 @@ import type { GraphNode, Node } from '../types' import { warn } from '../utils' import { useVueFlow } from './useVueFlow' -type NodeData = NonNullable & { id: string; type: NodeType['type'] } +interface NodeData { + id: string + type: NodeType['type'] + data: NonNullable | null +} /** * Composable for receiving data of one or multiple nodes @@ -38,14 +42,14 @@ export function useNodesData(_nodeIds: any): any { return { id: node.id, type: node.type, - data: node.data, + data: node.data ?? null, } } return null } - const data = [] + const data: NodeData[] = [] for (const nodeId of nodeIds) { const node = findNode(nodeId) @@ -54,7 +58,7 @@ export function useNodesData(_nodeIds: any): any { data.push({ id: node.id, type: node.type, - data: node.data, + data: node.data ?? null, }) } }