typescript - 找不到第三方模块的声明文件 - 如何声明和解决这些错误

标签 typescript vuejs2 typescript-typings vue-cli

我正在开发一个使用 typescript 的项目(使用 vue cli 3.0 生成)。

当我导入第三方模块时,出现如下错误:

Could not find a declaration file for module 'vue-slider-component'. 
'/home/wahid/Development/tealvalley-app/node_modules/vue-slider- 
component/dist/index.js' implicitly has an 'any' type.

解决此类问题的正确方法是什么?这些类型没有在 @types 包中定义,所以如果我自己定义它们,我应该把它保存在哪里?

最佳答案

What is the correct way to resolve these kind of issues?

创建文件vendor.d.ts有:

declare module 'vue-slider-component';

关于typescript - 找不到第三方模块的声明文件 - 如何声明和解决这些错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50360164/

相关文章:

javascript - Vue 对象未使用 axios POST 请求更新

javascript - 将文件内容读入vue组件内的数组

typescript - 如何覆盖 Angular-CLI 项目中的 node_module 错误类型?

typescript - 如何在 TypeScript 中引用属于联合类型的类型?

angular - 为什么 Typescript 无法推断 RxJs 流中的元组返回类型?

reactjs - 如何在 React 中使用 <select><option value={true}>?

typescript - Jest + Vue - 语法错误 : Unexpected token <

javascript - typescript promise 拒绝类型

javascript - Angular:我想将 div 的焦点从箭头键按钮移到另一个

typescript - 无法在 Apollo GraphQL 中定义自定义标量,TypeScript 输入有一些问题