Subscribe on changes!

TS2322 when using multiple checkboxes, bound to the same array

avatar
Aug 12th 2021

It would be great it you could provide an acutal TS example we can run.

avatar
Aug 12th 2021

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.

avatar
Aug 12th 2021

@johnsoncodehk can you confirm the problem is within vue?

avatar
Aug 12th 2021

I personal think this is InputHTMLAttributes types problem, hope this comment helpful: https://github.com/johnsoncodehk/vue-tsc/issues/57#issuecomment-897276138

avatar
Aug 16th 2021

@johnsoncodehk 77223df2 should fix the following cases:

  • checkbox with Array v-model value
  • <input> with non-primitive value 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.