vuejs / language-tools

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

v-model without v-model:modelValue not type checked in template when defineModel is used #4540

Closed davidmatter closed 4 weeks ago

davidmatter commented 1 month ago

Discussed in https://github.com/vuejs/language-tools/discussions/4529

Originally posted by **Quartoffel** July 4, 2024 Hey, I have a problem that my `v-model` (or any v-* for that matter) are neither type checked nor show any intellisense information. Normal props work fine (even :model-value). I am not sure why this happens. Maybe someone has any ideas how to debug/fix this. Here are two pictures to show the issue in action: 1. Here it correctly throws an error because of type mismatch ![Correctly checks the value](https://github.com/vuejs/language-tools/assets/174067704/5a3bf48c-0b56-4e80-b690-ddedfdf6c22e) 2. Here it does not (and also does not show any Intellisense on hover): ![Does not check model-value](https://github.com/vuejs/language-tools/assets/174067704/7f4a2708-7ca7-4c4b-982e-821804f778f1) Test2.vue is just: ``` ``` Information about my setup: System: OS: Windows 10 10.0.19045 CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor Memory: 16.40 GB / 31.93 GB Binaries: Node: 20.11.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD pnpm: 9.4.0 - ~\AppData\Local\pnpm\pnpm.CMD Browsers: Edge: Chromium (126.0.2592.87) Internet Explorer: 11.0.19041.4355 Vue - Official/vue-tsc Version: 2.0.26 Vue: 3.4.31 Typescript: 5.5.3
davidmatter commented 1 month ago

Doesn't work:

  <Test2 v-model="model"></Test2>

Works

  <Test2 v-model:modelValue="model"></Test2>

Per https://vuejs.org/guide/components/v-model#basic-usage the full notation is not required for unnamed defineModels.

so1ve commented 1 month ago

Caused by https://github.com/vuejs/language-tools/commit/01f64ee779592b6032d77336a17954b3b90e2f84?

Quartoffel commented 1 month ago

@so1ve Yes, i think this commit (or any introduced into 2.0.18) might be the cause. I tried with 2.0.17 and it correctly identifies the type of v-model. 2.0.18 shows the same symptoms as above.