Typescript 类型 导入使用报错, 不导入在原文件不报错,没明白错在哪?

interface MenuLeft {
  key:string,
  title:string,
  icon?:string,
  is_active:boolean,
  edit:boolean,
  link:string,
  children?:Array<MenuLeft>
}

// 在这测试是正常的
function menuIsActive(arr:Array<MenuLeft>, key:string|number):void{
  for(let i = 0,e=arr.length; i<e; i++){
    if( arr[i].children?.length>=1){     // 这里正常不报错
    }
  }
}

export type { MenuLeft }

在另一个 ts文件中 ,导入 使用就不正常了

import { MenuLeft } from '../types/data'
function menuIsActive(arr:Array<MenuLeft>, key:string|number):void{
  for(let i = 0, e=arr.length; i<e; i++){
    if( arr[i].children?.length>=1){     // 这行报错
    }
  }
}


ts 针对类型的导入导出有特殊的写法。
export type 也需要 import type。
比如 export type { Type } 需要 import type { Type } from "..."

报错信息是什么?

还有 if( arr[i].children?.length>=1){ 是不是该修改为

if( arr[i].children.length>=1){  

如有问题及时沟通