Description
TS plugin cannot be used with Vue files if the project does not contain tsconfig/jsconfig, or the Vue files are not included by tsconfig/jsconfig.
Steps to reproduce
- Clone https://github.com/johnsoncodehk/volar-starter
Since it is just for demonstration purposes, node_modules will not be installed. - Delete the
tsconfig.json
file in repo - Open the repo in VSCode, and open
src/components/HelloWorld.vue
- You should see TS errors reported due to missing dependencies, as shown below:
- Close
HelloWorld.vue
, opensrc/main.ts
, then re-openHelloWorld.vue
- Errors in the image above is now displayed in the wrong location (end of file)
Exploration
@vue/typescript-plugin
calls decorateLanguageService
and decorateLanguageServiceHost
at following code to modify the original languageService
and languageServiceHost
:
language-tools/packages/typescript-plugin/index.ts
Lines 62 to 63 in 3efa52d
This works well for ConfiguredProject
. But for InferredProject
, if you open the TS file before opening the Vue file, the modification of decorateLanguageService
is no longer valid, just like the original languageService
is no longer used. Therefore the mapping behavior of decorateLanguageService
is no longer valid.
Temporary Solutions
- Create a
jsconfig.json
file in project root with empty json object content{}
- Downgrade to 1.8.27 for now
Update: If you have the "Svelte for VS Code" extension installed, disabling it may avoid this problem.