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

[Bug]: Vue 3.4 - props and events are not inferred from defineModel #25626

Open
Vercadium opened this issue Jan 17, 2024 · 4 comments · Fixed by #26610
Open

[Bug]: Vue 3.4 - props and events are not inferred from defineModel #25626

Vercadium opened this issue Jan 17, 2024 · 4 comments · Fixed by #26610

Comments

@Vercadium
Copy link

Vercadium commented Jan 17, 2024

Describe the bug

Since defineModel became stable in Vue 3.4, this is now the recommended approach for using v-model.

Ideally Storybook would understand that defineModel is constructing the props/events for these (example below) and display them in the argTypes automatically. It would be preferred if both the type and JSDoc comment could be understood also.

After 3.4:

<script setup>
const model = defineModel();
</script>

<template>
  <input v-model="model" />
</template>

Before 3.4:

<script setup>
const props = defineProps(['modelValue']);
const emit = defineEmits(['update:modelValue']);
</script>

<template>
  <input
    :value="props.modelValue"
    @input="emit('update:modelValue', $event.target.value)"
  />
</template>
@shilman
Copy link
Member

shilman commented Jan 17, 2024

@chakAs3 @kasperpeulen will this be fixed moving the argtype inference to volar? #22285

@shilman shilman added the sev:S2 label Jan 17, 2024
@chakAs3
Copy link
Contributor

chakAs3 commented Jan 30, 2024

@shilman I adopted Volar quickly starting from April 2023 because it's the only assurance of staying current with Vue API changes. I've emphasized this point consistently, and if you review the pull request, you'll find comprehensive documentation outlining the desired format for the documentation and supported features

@larsrickert
Copy link
Contributor

@shilman Yes and no :D I quickly tested it out, with Volar the property will be added but the JSDoc / description and the corresponding event is missing. However, this feature is currently missing in Volar itself.

I added a feature request for Volar about this: vuejs/language-tools#3894

@ShGKme
Copy link

ShGKme commented Dec 8, 2024

Prop and event, including the type, is not gathered correctly.

Unfortunately, adding JSDoc with a description is still impossible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants