ts:报错Could not find a declaration file for module xxx
发布日期:2021-05-04 18:49:04 浏览次数:25 分类:精选文章

本文共 328 字,大约阅读时间需要 1 分钟。

问题

我们在 typescript 的项目中安装一些包的话,可能会报错 Could not find a declaration file for module 'xxx' ,这是因为这个包可能不是.ts文件而是.js文件,那么如何解决呢?

解决

如果有这个包的 ts 版本,则

npm install @types/xxx

否则,找到根目录下的 shims-vue-d.ts 文件

declare module '*.vue' {     import Vue from 'vue'  export default Vue}// 加上这个declare module 'xxx'

如果不在乎外部库的类型,可以直接设为

declare module '*'
上一篇:mongodb:更新、删除文档
下一篇:css:阅读知情同意书的勾选效果没法填满解决办法

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年03月20日 18时06分00秒