Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Vue 3 + TS event types error #29

@igbominadeveloper

Description

@igbominadeveloper

I created a reusable component with this template

<template>
  <label :for="label" class="mb-1 text-sm flex items-center">
    <input
      type="checkbox"
      :id="label"
      :checked="modelValue"
      class="mr-1 rounded-sm"
      @change="$emit('update:modelValue', $event.targe.checked)"
      v-bind="$attrs"
    />
    {{ label }}
  </label>

  <p>{{ error }}</p>
</template>

When I run vue-tsc, I get these errors:

src/components/BaseCheckbox.vue:8:43 - error TS2531: Object is possibly 'null'.

@change="$emit('update:modelValue', $event.target.checked)"


src/components/BaseCheckbox.vue:8:57 - error TS2339: Property 'checked' does not exist on type 'EventTarget'.

@change="$emit('update:modelValue', $event.target.checked)"
                                                         ~~~~~~~

To be honest, I am not sure this is a vue-tsc problem, I just don't know where to turn to. Any help is welcome

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions