Skip to content

[Vue TS Plugin] Modifications to InferredProject's language service were discarded #57630

Closed
@johnsoncodehk

Description

@johnsoncodehk

Acknowledgement

  • I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

Comment

Issue: vuejs/language-tools#3942

Vue TS Plugin modifies project language service at this line to handle virtual code mapping, which works well for ConfiguredProject. But for InferredProject, tsserver seems to always discard the existing language service when switching columns from .vue files to .ts files, and the newly created language service instance will not pass the plugin's create hook, so the plugin cannot modify it again.

However, the plugin's modifications to the language service host are retained, causing the vue file to display unmapped virtual code diagnostic messages.

Steps to reproduce

  1. Clone https://github.com/johnsoncodehk/volar-starter
    Since it is just for demonstration purposes, node_modules will not be installed.
  2. Delete the tsconfig.json file in repo
  3. Open the repo in VSCode, install https://marketplace.visualstudio.com/items?itemName=Vue.volar 2.0.4 and open src/components/HelloWorld.vue
  4. You should see TS errors reported due to missing dependencies, as shown below:
    image
  5. Close HelloWorld.vue, open src/main.ts, then re-open HelloWorld.vue
  6. Errors in the image above is now displayed in the wrong location (end of file)
    image

Metadata

Metadata

Assignees

Labels

ExternalRelates to another program, environment, or user action which we cannot control.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions