export 'xxxxxx' was not found in './type.ts'

253 阅读1分钟

开发过程中遇到一个非常神奇的问题。

那就是在类型文件.ts中定义了许多的类型,在引入到.tsx文件中使用时,有的类型可以正常通过eslint校验。但是有几个类型却报错说未导出,见下图:

warning.png

网上搜了下发现导出类型需要添加一个type说明。

answers.png

import { xxxx } from './type.ts'; // 会报错export 'xxxx' was not found in './type.ts'

import type  { xxxx } from './type.ts';  // bingo  警告消失了!

参考链接:# TypeScript export was not found