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

View File

@@ -9,7 +9,7 @@ import { Optional } from '../utils/types';
*/
export type NodeBase<
NodeData extends Record<string, unknown> = Record<string, unknown>,
NodeType extends string = string
NodeType extends string | undefined = string | undefined
> = {
/** Unique id of a node */
id: string;
@@ -20,7 +20,7 @@ export type NodeBase<
/** Arbitrary data passed to a node */
data: NodeData;
/** Type of node defined in nodeTypes */
type?: NodeType;
type: NodeType;
/** Only relevant for default, source, target nodeType. controls source position
* @example 'right', 'left', 'top', 'bottom'
*/