fix(core): correct isDef typeguard

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-04-03 08:53:33 +02:00
committed by Braks
parent da85ad0aca
commit eab9991762
+6 -2
View File
@@ -1,7 +1,11 @@
import type { Actions, Connection, Edge, GraphEdge, GraphNode, Node, State } from '~/types'
export function isDef<T>(val: T): val is NonNullable<T> {
return typeof unref(val) !== 'undefined'
type NonUndefined<T> = T extends undefined ? never : T
export function isDef<T>(val: T): val is NonUndefined<T> {
const unrefVal = unref(val)
return typeof unrefVal !== 'undefined' && unrefVal !== null
}
export function addEdgeToStore(edgeParams: Edge | Connection, edges: Edge[], onError: State['hooks']['error']['trigger']) {