type TreeNodeChildren, IdKey extends string, ChildrenKey extends string> = { [key in ChildrenKey]?: TreeNode[]; }; type TreeNodeId = { [key in IdKey]: IdType; }; type TreeNode = { [key: string]: any; }, // 节点数据 IdKey extends string = 'id', ChildrenKey extends string = 'children'> = { [key in IdKey]: Node[IdKey]; } & TreeNodeChildren & Node & TreeNodeId; type TreeNodeBase = TreeNode, string>; type EmptyTree = {}; type Tree = { [key: string]: any; }, // 节点数据 IdKey extends string = 'id', ChildrenKey extends string = 'children'> = EmptyTree | TreeNode | TreeNode[]; interface TreeNodeOptions { childrenKey?: string; idKey?: string; path?: string | ((node: Node) => Path); } export type { EmptyTree, Tree, TreeNode, TreeNodeBase, TreeNodeChildren, TreeNodeId, TreeNodeOptions };