Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
davidmatter opened this issue Jul 7, 2024 Discussed in #4529 · 3 comments · Fixed by #4598
Closed

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

davidmatter opened this issue Jul 7, 2024 Discussed in #4529 · 3 comments · Fixed by #4598
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@davidmatter
Copy link
Collaborator

Discussed in #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

  2. Here it does not (and also does not show any Intellisense on hover):
    Does not check model-value

Test2.vue is just:

<template>
  <div>{{ model }}</div>
</template>

<script setup lang="ts">
const model = defineModel<string>();
</script>

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
Copy link
Collaborator Author

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.

@davidmatter davidmatter added the bug Something isn't working label Jul 7, 2024
@so1ve so1ve added the good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first label Jul 8, 2024
@so1ve
Copy link
Member

so1ve commented Jul 8, 2024

Caused by 01f64ee?

@so1ve so1ve closed this as completed Jul 8, 2024
@so1ve so1ve reopened this Jul 8, 2024
@Quartoffel
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants