-
Notifications
You must be signed in to change notification settings - Fork 922
Open
DefinitelyTyped/DefinitelyTyped
#39343Description
I don’t understand what the flatData should be?
const testData = [
{ id: 1, title: 'Chicken', parent: null},
{ id: 2, title: 'Egg', parent: 1}
]
const tData = getTreeFromFlatData({
flatData: testData,
getKey: (node) => node.id,
getParentKey: (node) => node.parent,
rootKey: null
})
I got errors in TS:
"Property 'node' is missing in type '{ id: number; title: string; parent: number; }' but required in type 'TreeNode'."
In tree-data-utils.d.ts flatData is described as:
Array<TreeNode & TreePath & {lowerSiblingsCounts: number[]}>
Code works only if use any type:
const tData = getTreeFromFlatData({
flatData: testData as any,
getKey: (node: any) => node.id,
getParentKey: (node: any) => node.parent,
rootKey: null
})
Metadata
Metadata
Assignees
Labels
No labels