@@ -25,13 +25,24 @@ interface TreeNode {
2525 leaf? : boolean ;
2626}
2727
28+ interface TreeNodeMapEntry {
29+ key: string ;
30+ label: string ;
31+ childrenMap: Map <string , TreeNodeMapEntry >;
32+ data? : TreeNodeData ;
33+ }
34+
2835const buildTree = (reports : Report []): TreeNode [] => {
29- const rootMap = new Map <string , any >();
36+ const rootMap = new Map <string , TreeNodeMapEntry >();
3037
31- const ensureNode = (segments : string []): any => {
38+ const ensureNode = (segments : string []): TreeNodeMapEntry => {
3239 let map = rootMap ;
3340 let currentPath = " " ;
34- let node: any ;
41+ let node: TreeNodeMapEntry = {
42+ key: " " ,
43+ label: " " ,
44+ childrenMap: new Map (),
45+ };
3546
3647 segments .forEach ((segment ) => {
3748 currentPath = currentPath ? ` ${currentPath }/${segment } ` : segment ;
@@ -40,7 +51,7 @@ const buildTree = (reports: Report[]): TreeNode[] => {
4051 entry = {
4152 key: currentPath ,
4253 label: segment ,
43- childrenMap: new Map <string , any >(),
54+ childrenMap: new Map <string , TreeNodeMapEntry >(),
4455 };
4556 map .set (segment , entry );
4657 }
@@ -62,7 +73,7 @@ const buildTree = (reports: Report[]): TreeNode[] => {
6273 } as TreeNodeData ;
6374 }
6475
65- const mapToNodes = (map : Map <string , any >): TreeNode [] => {
76+ const mapToNodes = (map : Map <string , TreeNodeMapEntry >): TreeNode [] => {
6677 const nodes: TreeNode [] = [];
6778 for (const [, value] of map ) {
6879 const children = mapToNodes (value .childrenMap );
@@ -102,7 +113,7 @@ watch(
102113 const keys: Record <string , boolean > = {};
103114 const collect = (items : TreeNode []) => {
104115 for (const item of items ) {
105- if (item .children && item . children .length ) {
116+ if (item .children ? .length ) {
106117 keys [item .key ] = true ;
107118 collect (item .children );
108119 }
0 commit comments