Vue · VUE0047

Declare emitted events that collide with native listeners

Reports a template $emit of an event the component does not declare when it runs in a handler for the same native event, and that native event provably reaches the component's single native root element, where the parent's listener falls through.
VUE0047vite-doctor/vueattrswarnSuggestion

Run this rule

pnpm vite-doctor . --framework vue --extends auto,vue/strict --rules vue/attrs/require-explicit-emits

Why it matters

Vue 3 treats a parent's v-on listener as a fallthrough attribute unless the child declares the event in defineEmits or emits. A listener such as @click then lands on the child's root element as a native listener too, so a click that also calls $emit('click', payload) runs the parent's handler twice: once with the payload and once with the native MouseEvent.

Declare the event in defineEmits (or the emits option), or emit an event with a name that is not a native DOM event.

Example

Declare the emitted click event

Before

<template>
  <button type="button" @click="$emit('click', id)">Open</button>
</template>

After

<script setup lang="ts">
defineEmits(['click'])
</script>

<template>
  <button type="button" @click="$emit('click', id)">Open</button>
</template>
Copyright © 2026