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

defineProps conflicts with defineModel in template #4799

Closed robertmoura closed 2 months ago

robertmoura commented 2 months ago

Vue - Official extension or vue-tsc version

2.1.4

VSCode version

1.92.2

Vue version

3.5.0

TypeScript version

5.5.4

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M1
    Memory: 102.73 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.1.0 - /usr/local/bin/node
    Yarn: 4.4.0 - /usr/local/bin/yarn
    npm: 10.7.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 128.0.6613.114
    Edge: 128.0.2739.63
    Safari: 17.6

package.json dependencies

No response

Steps to reproduce

Create a Vue file with the following content:

<template>
    <div>
        {{ something }}
    </div>
</template>

<script lang="ts" setup>
defineProps({
    something: String,
});

defineModel();
</script>

What is expected?

The type of something should be string | undefined.

What is actually happening?

I am getting the following error:

Property 'something' does not exist on type 'CreateComponentPublicInstanceWithMixins<Readonly<__VLS_PublicProps & { "onUpdate:modelValue"?: ((modelValue: any) => any) | undefined; }>, {}, {}, {}, {}, ComponentOptionsMixin, ... 18 more ..., {}>'. ts-plugin(2339)

This also happens when I run vue-tsc.

Screenshot 2024-09-04 at 2 03 31 PM

Link to minimal reproduction

No response

Any additional comments?

It seems like there is a conflict between defineProps and defineModel.