代码之家  ›  专栏  ›  技术社区  ›  user762579

虚拟用户.jseslint如何消除警告:找不到模块的声明文件

  •  0
  • user762579  · 技术社区  · 7 年前

    单元测试一个组件,我必须导入一个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)?

    这是相关的包.json埃斯林特区块

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

    感谢您的反馈

    1 回复  |  直到 7 年前
        1
  •  0
  •   Ohgodwhy    7 年前

    看起来你在用打字。如果不存在该特定包的键入,则需要创建自己的定义文件:

    说出它的名字 vue-howlder.d.ts . 内容应为:

    declare module `vue-howler`
    

    确保您的 tsconfig 文件可以在您的打字目录的任何地方找到。

    推荐文章