TS报错:对象未定义

问题遇到的现象和发生背景

最近公司上的一个融合了TS的项目

问题相关代码,请勿粘贴截图
let treeData: TreeProps['treeData'] = [
   {
        title: 'Setup',
        key: '0-0',
        children: [
          {
            title: 'Display and brightness',
            key: '0-0-0',
            children: [
              { title: 'Rest screen style', key: '0-0-0-0' },
              {
                key: '0-0-0-1',
              },
              { title: 'Auto lock', key: '0-0-0-2' },
            ],
          },
          {
            title: 'Portable tools',
            key: '0-0-1',
            children: [{ title: 'gesture', key: '0-0-1-0' }],
          },
          {
            title: 'System settings',
            key: '0-0-2',
            children: [
              { title: 'Reset system', key: '0-0-2-0' },
              {
                title: 'Background refresh',
                key: '0-0-2-1',
              },
            ],
          },
        ],
  },
       {
        title: 'test',
        key: '0-1',
        children: [
          {
            title: 'Audio and video test',
            key: '0-1-0',
            children: [
              { title: 'Function panel', key: '0-1-0-0' },
              { title: 'Collect sound', key: '0-1-0-1' },
            ],
          },
        ],
      },
];
const onSelect: TreeProps['onSelect'] = (selectedKeys: any, info: any) => {
      console.log('selected', selectedKeys, info);
};

// 查询树节点的方法
const expandedKeys = ref<(string | number)[]>([]);
 const autoExpandParent = ref<boolean>(true);
const searchValues = ref<string>('');
watch(searchValues, value => {      
      if(value.length != 0){
      const expanded = treeData.map(item => {
        if(item.title.includes(value)){
          //console.log(item.key)
          return item.key;
        }
        
        return null;
      }).filter((item,i,self) => item && self.indexOf(item) === i);

      console.log('tree',expanded);
      console.log('datalist',treeData)
      console.log(value);

      expandedKeys.value= expanded as any;
      searchValues.value = value;
      autoExpandParent.value = true;
      }else{
        //折叠起来
        autoExpandParent.value =  false;
      }
     
    })

运行结果及报错内容

使用map遍历treeData是报错,显示对象未定义,请各位指教

value没给类型,expanded没给类型,map遍历的item没给类型。你这个TS结合js两种写法,写TS就严格按照TS的写法来