Skip to content

vue-tsc bug with checkboxes and numbers #1252

@Keztur

Description

@Keztur

The following checkbox in my Vue 3 project

<input
v-model="closed"
true-value="-1"
false-value="0"
type="checkbox"
@change="UpdateFilter()"
/>

creates the typescript error:
“Type ‘number’ is not assignable to type ‘any[] | Booleanish | undefined’.ts(2322)”

The variable “closed” is a number indeed. And I told vue to handle -1 as true and 0 as false, but vue-tsc doesn’t seem to recognize this.

My dev dependencies look like this:

//package.json
  "devDependencies": {
    "@vitejs/plugin-vue": "^2.3.1",
    "typescript": "^4.5.4",
    "vite": "^2.9.5",
    "vue-tsc": "^0.34.7"
  }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions