vuejs / language-tools

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

Newly created Vue app with TS doesn't recognize .vue files #4883

Open Laurelin opened 1 month ago

Laurelin commented 1 month ago

Vue - Official extension or vue-tsc version

1.8.27

VSCode version

1.93.1

Vue version

^3.4.29

TypeScript version

~5.4.0

System Info

System:
    OS: macOS 14.7
    CPU: (8) arm64 Apple M1 Pro
    Memory: 146.66 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 21.6.1 - /opt/homebrew/bin/node
    npm: 10.2.4 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 129.0.6668.59
    Safari: 18.0

package.json dependencies

No response

Steps to reproduce

run npm create vue@latest make sure to choose Typescript

go to Main.ts, import App from './App.vue'; has a red squiggle under './App.vue' error is 'Cannot find module './App.vue' or its corresponding type declarations.ts(2307)'

What is expected?

.vue files are recognized by TS

What is actually happening?

.vue files are not recognized by TS

Link to minimal reproduction

No response

Any additional comments?

There's a recent closed issue on this

https://github.com/vuejs/language-tools/issues/4118

Laurelin commented 1 month ago

The relevant tsconfig files:

tsconfig.json

{
  "files": [],

  "references": [
    {
      "path": "./tsconfig.node.json"
    },
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.vitest.json"
    }
  ]
}

and tsconfig.app.json

{
  "extends": "@vue/tsconfig/tsconfig.dom.json",
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
  "exclude": ["src/**/__tests__/*"],
  "compilerOptions": {
    "composite": true,
    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",

    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}
KazariEX commented 1 month ago

The latest version of extension is 2.1.6

dyllandry commented 5 days ago

I think I have the same issue. I generated an app using electron forge and their vite typescript template. All I've done is add an sfc, added lang="ts" and setup to both templates, and I've got this error now.

Here's the repo + branch that has the issue: https://github.com/dyllandry/desktop-clocks/tree/cannot-find-module

I'm using:

dyllandry commented 4 days ago

Downgrading @vue/language-server and @vue/typescript-plugin to 2.0.29 fixes this issue, but then I get the same errors as in this issue: https://github.com/vuejs/language-tools/issues/4706 . Following their solution of editing the package.json of @vue/language-server to not include the ~ in its @volar/language-server dependency and reinstalling its deps worked. That kind of solution would undo itself if I ever reinstall @vue/typescript-plugin, though.