Skip to content

v-model and null value on radio button with vue-tsc v1.1.3 #2415

@cexbrayat

Description

@cexbrayat

The following component throws with v1.1.13:

<script setup lang="ts">
import { ref } from 'vue'
const count = ref<number | null>(null)
</script>

<template>
  <input v-model="count" type="radio" v-for="i in 3" :key="i" :value="i" />
</template>

with:

src/App.vue:7:10 - error TS2322: Type 'number | null' is not assignable to type 'any[] | Set<any> | Booleanish | undefined'.
  Type 'null' is not assignable to type 'any[] | Set<any> | Booleanish | undefined'.

7   <input v-model="count" type="radio" v-for="i in 3" :key="i" :value="i" />
           ~~~~~~~

  node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts:646:3
    646   checked?: Booleanish | any[] | Set<any> // for IDE v-model multi-checkbox support
          ~~~~~~~
    The expected type comes from property 'checked' which is declared here on type 'ElementAttrs<InputHTMLAttributes>'

undefined is allowed, but null is no longer possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions