TS检测的报错截图如下:
问题描述:
当我们用 TS 去写项目代码时,并且引入了一个没有类型声明的 npm 包的时候,此时 TS 会检测提示导入了一个不明物体!于是,强迫症表示太难受了。。。咋办呢?
1、最简单粗暴的解决方法:
注释TS检测 @ts-ignore
2、理想解决方案:
在根目录(src)下面帮忙声明一下该类型,新建一个 XXX.d.ts 文件
参考资料:
摘自:typescript error ts2307 cannot find module or its corresponding type declarations-掘金
摘自:How to Fix cannot find module and its corresponding type declarations