JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElement

1,334 阅读1分钟

该项目是vue2.6,想用jsx语法,在tsconfig.json中增加"jsx": "preserve"配置后,vscode中出现如下提示信息: image.png

参考回答

{
  "compilerOptions": {
    "composite": true,
    "module": "esnext",
    "moduleResolution": "node"
  },
  "include": [
    "vite.config.ts"
  ],
  "vueCompilerOptions": {
    "experimentalCompatMode": 2, // delete after migrating to vue3 (or nuxt3)
    "experimentalTemplateCompilerOptions": {
      "compatConfig": {
        "MODE": 2
      } // delete after migrating to vue3 (or nuxt3)
    }
  }
}

image.png

这其实是vscode的Volar插件报出的提示,如果解决不了还换成为Vue2准备的Vetur插件,就不报错了。