Skip to content

Commit fcf7024

Browse files
committed
chore: update ts define
1 parent 0ff4afa commit fcf7024

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/utils/treeUtil.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import * as React from 'react';
22
import toArray from 'rc-util/lib/Children/toArray';
33
import warning from 'rc-util/lib/warning';
4-
import { DataNode, FlattenNode, NodeElement, DataEntity, Key, EventDataNode } from '../interface';
4+
import {
5+
DataNode,
6+
FlattenNode,
7+
NodeElement,
8+
DataEntity,
9+
Key,
10+
EventDataNode,
11+
} from '../interface';
512
import { getPosition, isTreeNode } from '../util';
613
import { TreeNodeProps } from '../TreeNode';
714

@@ -45,12 +52,15 @@ export function warningWithoutKey(treeData: DataNode[] = []) {
4552
*/
4653
export function convertTreeToData(rootNodes: React.ReactNode): DataNode[] {
4754
function dig(node: React.ReactNode): DataNode[] {
48-
const treeNodes: NodeElement[] = toArray(node);
55+
const treeNodes = toArray(node) as NodeElement[];
4956
return treeNodes
5057
.map(treeNode => {
5158
// Filter invalidate node
5259
if (!isTreeNode(treeNode)) {
53-
warning(!treeNode, 'Tree/TreeNode can only accept TreeNode as children.');
60+
warning(
61+
!treeNode,
62+
'Tree/TreeNode can only accept TreeNode as children.',
63+
);
5464
return null;
5565
}
5666

@@ -161,7 +171,11 @@ export function traverseDataNodes(
161171
// Process children node
162172
if (children) {
163173
children.forEach((subNode, subIndex) => {
164-
processNode(subNode, subIndex, { node, pos, level: parent ? parent.level + 1 : -1 });
174+
processNode(subNode, subIndex, {
175+
node,
176+
pos,
177+
level: parent ? parent.level + 1 : -1,
178+
});
165179
});
166180
}
167181
}
@@ -278,7 +292,9 @@ export function getTreeNodeProps(
278292
return treeNodeProps;
279293
}
280294

281-
export function convertNodePropsToEventData(props: TreeNodeProps): EventDataNode {
295+
export function convertNodePropsToEventData(
296+
props: TreeNodeProps,
297+
): EventDataNode {
282298
const {
283299
data,
284300
expanded,

0 commit comments

Comments
 (0)