null values in nuxt ui input
Hi there!
It looks like after a recent change of something, nuxt ui no longer allows certain values in a
UInput
's v-model? I get the following error when trying to display a possible null value in an input
It also appears that boolean options are no longer allowed in select menus either... Or an array of strings? Though that might be due to the null value
If this change was intentional there a correct way to handle these kinds of data errors? It might just be a bad implementation my end if I'm using boolean values in select's for example
I am using @nuxt/ui: ^2.14.2
. The error is also present on ^2.15.2
which is the latest version
The code used to build fine so I'm not sure what changed
I'm also really confused as I only get the errors when running nuxi typecheck
, but not in my local vscode
Maybe it was an update to vue-tsc
?10 Replies
Hell I can't even use a boolean anymore it seems with a
USelectMenu
?
And I get this error with the v-model, where the property's type is boolean|undefined
error TS2322: Type 'boolean | undefined' is not assignable to type 'string | number | Record<string, any> | unknown[] | undefined'.
Your problem seems to be with the boolean value.
No change on the component side: https://github.com/nuxt/ui/commits/dev/src/runtime/components/forms/Input.vue
Sorry I forgot to submit my edit to that message you're replying to. Added an example
I'm going to raise an issue on the github, but I think it might be a problem with
vue-tsc
Ohh it's a SelectMenu not a UInput
I have similar typeerrors with both components
I'm trying to set up a small proper example with a
UInput
now
I was able to fix my inputs by type casting to string|undefined
which while not ideal, works. But this here with the select is a blocker as I can't type cast my way out of it
...well I can but it's a mess and I'd rather just fix the problem
Here's the same with an input. This one also doesn't compile
For me this example works without TS issues :
(using edge)
Yeah that one doesn't work for me on my local. I get this error
What version of vue-tsc are you using?
https://stackblitz.com/edit/nuxt-ui-gyskbt?file=package.json
Nuxt ui 2.15.2
https://nuxt.com/docs/guide/concepts/typescript
@Wazbat
You may experience issues with the latest vue-tsc and vite-plugin-checker, used internally when type checking. For now, you may need to stay on v1 of vue-tsc, and follow these upstream issues for updates: fi3ework/vite-plugin-checker#306 and vuejs/language-tools#3969.
Ahhh let me test that
Ohh even with that I still get the same error with your code
https://stackblitz.com/edit/nuxt-ui-eqhn2j?file=package.json @Valentin
I've opened a github issue for this
https://github.com/nuxt/ui/issues/1710
GitHub
Unable to use boolean values with USelectMenu or null with UInput ·...
Environment Operating System: Windows_NT Node Version: v20.12.2 Nuxt Version: 3.10.3 CLI Version: 3.10.1 Nitro Version: 2.9.1 Package Manager: [email protected] Builder: - User Config: app, colorMode, ui,...