Skip to content

Commit 1184941

Browse files
committed
fix(core,composables): correct typing of useNodesData return
1 parent c7957df commit 1184941

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/core/src/composables/useNodesData.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import type { GraphNode, Node } from '../types'
44
import { warn } from '../utils'
55
import { useVueFlow } from './useVueFlow'
66

7-
type NodeData<NodeType extends Node = GraphNode> = NonNullable<NodeType['data']> & { id: string; type: NodeType['type'] }
7+
interface NodeData<NodeType extends Node = GraphNode> {
8+
id: string
9+
type: NodeType['type']
10+
data: NonNullable<NodeType['data']> | null
11+
}
812

913
/**
1014
* Composable for receiving data of one or multiple nodes
@@ -38,14 +42,14 @@ export function useNodesData(_nodeIds: any): any {
3842
return {
3943
id: node.id,
4044
type: node.type,
41-
data: node.data,
45+
data: node.data ?? null,
4246
}
4347
}
4448

4549
return null
4650
}
4751

48-
const data = []
52+
const data: NodeData<Node>[] = []
4953

5054
for (const nodeId of nodeIds) {
5155
const node = findNode(nodeId)
@@ -54,7 +58,7 @@ export function useNodesData(_nodeIds: any): any {
5458
data.push({
5559
id: node.id,
5660
type: node.type,
57-
data: node.data,
61+
data: node.data ?? null,
5862
})
5963
}
6064
}

0 commit comments

Comments
 (0)