devtools icon indicating copy to clipboard operation
devtools copied to clipboard

`event listeners` should consider camelCase emits

Open twisterniq opened this issue 1 year ago • 2 comments

event listeners shows Not declared for a camelCase emit, this is not correct:

image

The code is:

App.vue:

<template>
  <Child @input-text="console.log('inputText')" />
</template>

<script setup>
import Child from './Child.vue';
</script>

Child.vue

<template>
  <input @input="emit('inputText')" />
</template>

<script setup>
const emit = defineEmits([
  'inputText',
])
</script>

Tested using Chrome extension Vue.js devtools, version 7.5.6.

twisterniq avatar Oct 30 '24 11:10 twisterniq

same issue

Image

yourock1988 avatar Mar 05 '25 16:03 yourock1988

Ran into this as well. This means that when using the defineModel macro, where the event emitted is in camel case (update:modelValue), the devtools give a "Not declared" warning, even though the update event triggers and functions normally.

If the component specifies defineEmits(['update:model-value']), i.e. explicit kebab-case, the event listener is considered Declared. But it seems a bit much to add that to all components in the code just to get rid of the warning in the devtools. It's one of the two parts that defineModel does, so also redundant to specify that.

After a (quick) look in the repo code, it seems it's partly handled in process.ts, processEventListeners function. Couldn't spend more time to find out more about the instance.type.emits. The type could come from here, but no obvious emits there. It probably happens somewhere else. Could come from the any type App in the same file.

razofz avatar Nov 20 '25 12:11 razofz