Data Edge
An edge that displays one field from the source node’s data object.
Additional type safety
When creating new edges of this type, you can use TypeScript’s satisfies predicate along
with the specific type of a node in your application to ensure the key property of the
edge’s data is a valid key of the node’s data.
type CounterNode = Node<{ count: number }>;
const initialEdges = [
{
id: 'edge-1',
source: 'node-1',
target: 'node-2',
type: 'dataEdge',
data: {
key: 'count',
} satisfies DataEdge<CounterNode>,
},
];If you try to use a key that is not present in the node’s data, TypeScript will show an error message like:
ts: Type ‘“value”’ is not assignable to type ‘“count”’.
Last updated on