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 typescript error when using label-key InputMenu/SelectMenu #3670

Closed
Oui-Dev opened this issue Mar 24, 2025 · 4 comments · Fixed by #3331
Closed

v-model typescript error when using label-key InputMenu/SelectMenu #3670

Oui-Dev opened this issue Mar 24, 2025 · 4 comments · Fixed by #3331
Labels
bug Something isn't working typescript v3 #1289

Comments

@Oui-Dev
Copy link

Oui-Dev commented Mar 24, 2025

Environment

  • Operating System: Linux
  • Node Version: v20.18.1
  • Nuxt Version: 3.16.1
  • CLI Version: 3.23.1
  • Nitro Version: 2.11.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools, typescript, css, compatibilityDate, devServer, vite, runtimeConfig, app, ui, modules
  • Runtime Modules: @nuxt/[email protected], @pinia/[email protected], pinia-plugin-persistedstate/[email protected]
  • Build Modules: -
  • Typescript: 5.8.2
  • Vue-tsc: 2.2.8

Is this bug related to Nuxt or Vue?

Nuxt

Version

v3.0.1

Reproduction

// will trigger typescript error on v-model
<USelectMenu
    v-model="memberForm.user"
    :items="addableUsers"
    label-key="email"
/>
// will trigger typescript error on v-model
<USelectMenu
    v-model="memberForm.user"
    :items="addableUsers"
    label-key="email"
    :value-key="undefined"
/>
// will work but i need to handle label display manually using slot
<USelectMenu
    v-model="memberForm.user"
    :items="addableUsers"
/>

Description

I'm currently migrate my project to NuxtUi V3 and I have some issues with <UInputMenu /> and <USelectMenu />. On my selects I want to retrieve the full object selected so I don't set value-key but for display purpose I use the label-key props, however when I do this I get this typescript error on the v-model :

Unable to assign type 'User | undefined' to type 'string | undefined'.
Unable to assign type 'User' to type 'string'. ts-plugin(2322)

After some research, I think the label-key alter the value-key type and that's what triggers the error.

Additional context

No response

Logs

@Oui-Dev Oui-Dev added bug Something isn't working triage v3 #1289 labels Mar 24, 2025
@benjamincanac
Copy link
Member

@sandros94 Does #3331 solves this?

@sandros94
Copy link
Member

@benjamincanac yes it does

@Oui-Dev
Copy link
Author

Oui-Dev commented Mar 24, 2025

Wow thanks for your reactivity guys !
Is there an expected date for this fix ?
Actually we use <!-- @vue-ignore --> to pass the typecheck but that's not really safe 😅

@carlos-duran
Copy link

carlos-duran commented Mar 27, 2025

I was about opening an issue about this 😅
Thank you for the fix, by the moment I'll use <!-- @vue-ignore -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typescript v3 #1289
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants