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 403 forks source link

vue-tsc@2.1.6 reports variable as unused despite being used in template #4915

Closed WIStudent closed 1 month ago

WIStudent commented 1 month ago

Vue - Official extension or vue-tsc version

vue-tsc@2.1.6

VSCode version

I did not use VSCode

Vue version

vue@3.5.11

TypeScript version

typescript@5.6.3

System Info

No response

package.json dependencies

No response

Steps to reproduce

  1. Create a simple component like this: FooBar.vue

    <script setup lang="ts">
    const foo = "bar";
    </script>
    
    <template>
      <div>
          {{ foo }}
      </div>
    </template>
  2. Run npx vue-tsc --noEmit

What is expected?

vue-tsc should run without errors.

What is actually happening?

vue-tsc returns the following error:

src/components/FooBar.vue:2:7 - error TS6133: 'foo' is declared but its value is never read.

2 const foo = "bar";

Link to minimal reproduction

No response

Any additional comments?

This does not happen if I downgrade to vue-tsc@2.1.4

WIStudent commented 1 month ago

Nevermind, I still had

"vueCompilerOptions": {
    "skipTemplateCodegen": true
  }

inside my tsconfig.json. Removing it fixed the issue.