vue3+ts warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any

vue3+ts 控制台警告 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any

解决方法1:找到并打开你的.eslintrc.js文件rules里面加上 “@typescript-eslint/no-explicit-any”: [“off”] 就能关闭这个eslint对使用any类型的警告了。

rules: {
    
    
    "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
    "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
    "@typescript-eslint/no-explicit-any": ["off"], // 把我加上
  },

解决方法2:如果你的配置项都集中在package.json文件的的话,找到并打开你的package.json文件eslintConfigrules里面加上 “@typescript-eslint/no-explicit-any”: [“off”] 就能关闭这个eslint对使用any类型的警告了。

"eslintConfig": {
    
    
    "root": true,
    "env": {
    
    
      "node": true
    },
    "extends": [
      "plugin:vue/vue3-essential",
      "eslint:recommended",
      "@vue/typescript/recommended"
    ],
    "parserOptions": {
    
    
      "ecmaVersion": 2020
    },
    "rules": {
    
    
      "@typescript-eslint/no-explicit-any": ["off"] // 把我加上
    }
  },

猜你喜欢

转载自blog.csdn.net/weixin_42744724/article/details/128898447
今日推荐