vue.js eslint如何摆脱警告:找不到模块的声明文件

时间:2018-09-20 15:08:54

标签: vue.js eslint

单元测试组件,我必须导入一个mixin(vue-howler)

import VueHowler from "vue-howler";  

我收到有关隐式任何...的导入警告

[ts]
Could not find a declaration file for module 'vue-howler'. '/Users/yves/Developments/WIP/VUE.JS-cli-3/3-chocha-home-content/chocha/node_modules/vue-howler/dist/vue-howler.common.js' implicitly has an 'any' type.
  Try `npm install @types/vue-howler` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-howler';`

如何解决此警告?没有@ types / vue-howler)吗?

这是相关的package.json eslint块

package.json

....
 "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "@vue/prettier"
    ],
    "rules": {
      "no-console": 0
    },
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
 ....

感谢您的反馈

1 个答案:

答案 0 :(得分:0)

您似乎正在使用打字稿。如果该特定程序包不存在任何类型,则需要创建自己的定义文件:

将其命名为end。内容应为:

vue-howlder.d.ts

确保您的declare module `vue-howler` 文件可以在您键入目录的任何位置找到该文件。