[Vuejs]-Why does VS Code fail type acquisition for Vue?

0👍

I examined the Automatic Type Acquisition cache in my PC, which is C:\Users\<username>\AppData\Local\Microsoft\TypeScript\3.8\

The immediate cause seems to be a missing entry in C:\Users\<username>\AppData\Local\Microsoft\TypeScript\3.8\node_modules\types-registry\index.json. It’s a ~560KB JSON file which contains the latest version numbers for various NPM packages under the @types scope.

For some reason, this JSON file does not contain an entry for vue, even though the @types/vue package exists on NPM. Strangely enough, it does contain entries for several packages that depend on Vue, such as vue-markdown and vue-ls.

When I added "vue-ls" to my jsconfig.json:

{
  "compilerOptions": {
    "checkJs": true
  },
  "typeAcquisition": {
    "include": [
      "jquery",
      "react",
      "vue-ls"
    ]
  }
}

…TypeScript downloaded @types/vue-ls into its cache. This pulls in the type definitions in the vue package, which makes the type checks work for Vue.js.

Leave a comment