TS2322 when using multiple checkboxes, bound to the same array
Version
3.2.1
Reproduction link
Steps to reproduce
Hey,
when using multiple checkboxes, which are bound to the same array TS2322 arises. See the following image:
What is expected?
There shouldn't be a TS error when using an array as v-model.
checkbox's v-model prop is checked(https://v3.vuejs.org/guide/forms.html#basic-usage), and checked type is Booleanish = boolean | 'true' | 'false'(https://github.com/vuejs/vue-next/blob/7ffa225aa334f0fd7da6ba30bee9109de3597643/packages/runtime-dom/types/jsx.d.ts#L458), so number[] can't assign to checked in expected.
What is actually happening?
TS2322 error, since checked needs to be Booleanish.
Sorry, I hope this helps: https://codesandbox.io/s/admiring-sky-ucmn0?file=/src/components/HelloWorld.vue
It seems to be only showing this in VS Code with Volar, at least from what I can tell.
I personal think this is InputHTMLAttributes types problem, hope this comment helpful: https://github.com/johnsoncodehk/vue-tsc/issues/57#issuecomment-897276138
@johnsoncodehk 77223df2 should fix the following cases:
- checkbox with Array
v-model
value <input>
with non-primitivevalue
bindings
However the case for radio needs to be fixed in Volar. Volar is mapping the v-model
on a radio input to checked
, which is incorrect:
<input type="radio" v-model="selected" :value="foo">
<input type="radio" v-model="selected" :value="bar">
Here v-model
's binding type should be the same as :value
. Not sure if this can be inferred, but at least it should be any
instead of Booleanish
.