vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.88k stars 408 forks source link

JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists #732

Closed reazan closed 3 years ago

reazan commented 3 years ago

Hello, I have a problem after the update of Volar at 21/11/2021, 12:46:47

I have a Vue2@2.6.12 project (no cli) with

image

All the SFC files has this error but webpack still work. Last week didn't have the problem

Thanks in advance and for the awesome tool :)

reazan commented 3 years ago

Update: the problem seems to appear only to Vue2 SFC. In a new Vite + Vue3 project the issue is not present. Kind Regards

estebangmt commented 3 years ago

For me rolling back to 29.5 fixed the issue for now.

rchl commented 3 years ago

Did you follow the "Setup for Vue 2" instructions at https://github.com/johnsoncodehk/volar/tree/master/extensions/vscode-vue-language-features#using ?

For me this error shows up only when those steps are not performed.

maninak commented 3 years ago

I use vetur with nuxt (nuxt2 and vue3 syntax via @nuxtjs/composition-api).

As suggested by @rchl (thank you!), I RTFMd and these steps fixed it for me:

  1. update package.json as follows:
    // package.json
    {
      "devDependencies": {
        "@vue/runtime-dom": "latest"
      }
    }
  2. yarn install (so that the lockfile is rebuilt with the new dynamic entry "latest")
  3. update tsconfig.json as follows;
    // tsconfig.json{
      "compilerOptions": {
        ...
      },
      "vueCompilerOptions": {
        "experimentalCompatMode": 2, // delete after migrating to vue3 (or nuxt3)
        "experimentalTemplateCompilerOptions": {
          "compatConfig": { "MODE": 2 } // delete after migrating to vue3 (or nuxt3)
        }
      }
    }
  4. reload vscode

I wish vetur could detect this error and hint at me that I need to follow these steps, without having to google around. :pray:

reazan commented 3 years ago

Thanks everyone for your comments.

I tried a couple of things and what fixed the issue for me is following the "Setup for Vue 2" instructions and basically install the "@vue/runtime-dom" and added to the tsconfig.json (Thanks @rchl)

After that the only issue I get is a "JSX element type '__VLS_9' does not have any construct or call signatures.ts(2604)" on a "hgroup" tag that it is basically deprecated so I think it is ok

Thanks again I am closing the issue