Skip to content

False positive errors at end-of-file #3942

Closed
@johnsoncodehk

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

  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, 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

Exploration

@vue/typescript-plugin calls decorateLanguageService and decorateLanguageServiceHost at following code to modify the original languageService and languageServiceHost:

decorateLanguageService(files, info.languageService);
decorateLanguageServiceHost(files, info.languageServiceHost, ts);

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

  1. Create a jsconfig.json file in project root with empty json object content {}
  2. Downgrade to 1.8.27 for now

Update: If you have the "Svelte for VS Code" extension installed, disabling it may avoid this problem.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions