[TS] Use custom TreeNode type (#3164)

This commit is contained in:
Chenlei Hu
2025-03-20 12:03:47 -04:00
committed by GitHub
parent b162963593
commit d9ae6cb395
12 changed files with 25 additions and 47 deletions

View File

@@ -1,4 +1,4 @@
import type { TreeNode } from 'primevue/treenode'
import type { TreeNode } from '@/types/treeExplorerTypes'
export function buildTree<T>(items: T[], key: (item: T) => string[]): TreeNode {
const root: TreeNode = {
@@ -45,7 +45,7 @@ export function flattenTree<T>(tree: TreeNode): T[] {
while (stack.length) {
const node = stack.pop()!
if (node.leaf && node.data) result.push(node.data)
stack.push(...(node.children || []))
stack.push(...(node.children ?? []))
}
return result
}