Subscribe on changes!

Vue 3.3.4. defineEmits doesn't setup extended events

avatar
May 31st 2023

Vue version

3.3.4

Link to minimal reproduction

https://github.com/tragid/vue-default-export-error/tree/vue-3.3.4-emit-errors

Steps to reproduce

  1. Create BaseEmits type:
export interface BaseEmits {
  (e: 'input-event', value: string): void;
  (e: 'change-event', value: string): void;
}
  1. Create component and defineEmits with extending BaseEmits interface ComponentEmits extends BaseEmits { (e: 'blur-event', value: string): void; (e: 'focus-event', value: string): void; }

const emit = defineEmits();

  1. Facing runtime exceptions on DEV and not setup extended emits on prod:
runtime-core.esm-bundler.js:41 [Vue warn]: Component emitted event "input-event" but it is neither declared in the emits option nor as an "onInput-event" prop.

runtime-core.esm-bundler.js:41 [Vue warn]: Component emitted event "change-event" but it is neither declared in the emits option nor as an "onChange-event" prop.

What is expected?

defineEmits can support extended events

What is actually happening?

Facing runtime exceptions on DEV and not setup extended emits on prod:

runtime-core.esm-bundler.js:41 [Vue warn]: Component emitted event "input-event" but it is neither declared in the emits option nor as an "onInput-event" prop.

runtime-core.esm-bundler.js:41 [Vue warn]: Component emitted event "change-event" but it is neither declared in the emits option nor as an "onChange-event" prop.

System Info

No response

Any additional comments?

No response

avatar
Nov 7th 2023

Before the fix gets merged, you can use https://github.com/unplugin/unplugin-vue-complex-types as a temporal solution.