vuejs / language-tools

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

Regression in vue-tsc@2.0.11 compared to vue-tsc@2.0.7: Exclusions from tsconfig.json are ignored #4241

Open MaxVanDeursen opened 5 months ago

MaxVanDeursen commented 5 months ago

Information

Package + version: vue-tsc@2.0.11 Previous package + version used: vue-tsc@2.0.7 Scenario: I have a Vue component within which I have Typescript errors. I have excluded this specific file through the tsconfig.json's exclude configuration. Using version 2.0.7, this worked as expected, where the errors did not trigger any while using vue-tsc. Updating to version 2.0.11 appears to ignore the aforementioned exclusion. The result of this is that this error now shows up when running vue-tsc.

Reproduction

Steps:

  1. Open https://stackblitz.com/edit/vitejs-vite-ksrj14?file=package.json
  2. From the console, run npx vue-tsc. Note that the version of vue-tsc is 2.0.7. Note that the command does not output any errors.
  3. Change the version of vue-tsc to 2.0.11, e.g. through running npm i vue-tsc@2.0.11 --save-dev
  4. Run npx vue-tsc again.

Expected: As the error is in src/App.vue, and this file is excluded from type checking within tsconfig.json, no errors are raised, as is previously the case.

Actual: An error is raised due to the error within src/App.vue: image

Removing the empty Empty.vue file results in the App.vue being successfully ignored from type checking.

johnsoncodehk commented 5 months ago

This is an expected error, the tsconfig exclude option does not prevent checking of referenced files, see https://stackoverflow.com/a/64885126.

The presence or absence of Empty.vue causing inconsistencies is an edge case. Errors in App.vue will only be found when global types are generated, but since global types will only be generated from .vue files included in tsconfig, App.vue will only report it when tsconfig includes more than one .vue file.

To ignore errors in App.vue, you may consider using @vue-ignore / @vue-skip instead.

<template>
  <!-- @vue-ignore -->
  <button :type="3"></button>
</template>
MaxVanDeursen commented 5 months ago

@johnsoncodehk Thank you for your explanation regarding the tsconfig exclude option and for a solution to my problem. I have opted for the <!-- @vue-ignore --> annotation, successfully ignoring the type warning and resulting in a successful vue-tsc run.

Is the difference in behaviour between the versions 2.0.7 and 2.0.11 worth investigating, leaving this issue relevant? Feel free to close this issue if this is not the case.