From c927929b2c67b2f8cb288e296060bd9c4805299f Mon Sep 17 00:00:00 2001 From: moklick Date: Tue, 21 Jul 2020 10:47:39 +0200 Subject: [PATCH] refactor(utils): set return type of getOutgoers to node[] --- src/utils/graph.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/graph.ts b/src/utils/graph.ts index 5d6f7f4c..8b899913 100644 --- a/src/utils/graph.ts +++ b/src/utils/graph.ts @@ -7,13 +7,13 @@ export const isEdge = (element: Node | Connection | Edge): element is Edge => export const isNode = (element: Node | Connection | Edge): element is Node => 'id' in element && !('source' in element) && !('target' in element); -export const getOutgoers = (node: Node, elements: Elements): Elements => { +export const getOutgoers = (node: Node, elements: Elements): Node[] => { if (!isNode(node)) { return []; } - const outgoerIds = (elements as Edge[]).filter((e) => e.source === node.id).map((e) => e.target); - return elements.filter((e) => outgoerIds.includes(e.id)); + const outgoerIds = elements.filter((e) => isEdge(e) && e.source === node.id).map((e) => (e as Edge).target); + return elements.filter((e) => outgoerIds.includes(e.id)) as Node[]; }; export const removeElements = (elementsToRemove: Elements, elements: Elements): Elements => {