Update nodes.ts to allow strong NodeType

Update the NodeBase type to have a stronger NodeType field that can be undefined even if you specifically define it.
This commit is contained in:
Ben Chidlow
2024-09-17 13:42:21 +08:00
committed by GitHub
parent ce51e02acf
commit 64c36470cd
+2 -2
View File
@@ -9,7 +9,7 @@ import { Optional } from '../utils/types';
*/ */
export type NodeBase< export type NodeBase<
NodeData extends Record<string, unknown> = Record<string, unknown>, NodeData extends Record<string, unknown> = Record<string, unknown>,
NodeType extends string = string NodeType extends string | undefined = string | undefined
> = { > = {
/** Unique id of a node */ /** Unique id of a node */
id: string; id: string;
@@ -20,7 +20,7 @@ export type NodeBase<
/** Arbitrary data passed to a node */ /** Arbitrary data passed to a node */
data: NodeData; data: NodeData;
/** Type of node defined in nodeTypes */ /** Type of node defined in nodeTypes */
type?: NodeType; type: NodeType;
/** Only relevant for default, source, target nodeType. controls source position /** Only relevant for default, source, target nodeType. controls source position
* @example 'right', 'left', 'top', 'bottom' * @example 'right', 'left', 'top', 'bottom'
*/ */