Subscribe on changes!

Component v-model throw warning "Component emitted event "update:modelValue" but it is neither declared in the emits option nor as an "onUpdate:modelValue" prop." when using with interface

avatar
Jun 26th 2023

Vue version

3.3.4

Link to minimal reproduction

https://play.vuejs.org/#eNqNVMFy0zAQ/ZVFB5zOhOTAzThmaKcMcIAOMHDRxbE3iVpZ8khy0o7xv7Mr13ETKEMukXbf7r7dfVYn3jXNYt+iSEXmS6eaAB5D2+TSqLqxLkAHDjfQw8bZGhKCJkfX1U7p6srSxaAJj4jF8tTM2ZM30khTWuMD1H4LK845Sz6g1hZ+WqerF8mFNNlyoEDF6RKwbnQRkG4AXUdxfc/H7Kzs/lVtK9QrKQgiRZ6dEaD4bHlMJuYieGKyUdvFrbeGGu84qxQlBSiN7ksTFDGVIoXoYV9BRA+foi24FuejvdxhefcX+62/Z5sUNw49uj1KcfSFwm0xDO7rb5/xns5HJ7XSakL/w/kVvdUtcxxgl62piPYTXGT7Me5Ime13f30f0PixKSbKyD7ipaD98Kyea32i+3rxOsZJ09MU/9zyuYZAF2ZLawmUMJfuVFFzHncbsDqVFqEi0gR0m6JEeG8tBcAMU0japqIVpnHdPwpN+Dns+f9tCmtrNRYGfoEPjrqmg13fYhnoYNp6je4ihb1VVI8LDFpsnG08qbHCjTJ4w7esm9KnhXno89nFyGq5hNUqh7Bz9gCHwhHNLSgDnIyqg9pA6wfbSP+ycEBLRFN5buW0tzMn9RnbXBcuOSF7Vv9g3R0Y6+pCTyXDQ0MEOLWnpmmLcFBhxyU8h0Y3X6hbLvXyf4oNQ8JahWlI13zLOBMNJtJpaZh1zV9isBDQh2m+z4Ry5FhmAMYtEnAURUaTz2cdA1iFJMAUuFxOuny08c+RzJwZ1riY9jZCSOGPJ9IjJaAqY6vnmSLT2XMKiwqIGUfa/VEU06M1GqaHK0ZlylBPT56p2KwUEP1Pn6b+N65m54g=

Steps to reproduce

Initial:

  • Make interface Foo: interface Foo { (e: 'update:modelValue', value?: boolean | string | object | number): void }

Using with extends interface:

  • create interface Bar extends Foo
  • pass interface Foo to defineEmits interface Bar extends Foo { (e: 'bar'): void } ==>throw warning when updating modelValue

Using with type intersection:

  • create type Bars = Foo & { (e: 'bar'): void } ==> work normal

What is expected?

update modelValue working without warning

What is actually happening?

update modelValue throw warning: Component emitted event "update:modelValue" but it is neither declared in the emits option nor as an "onUpdate:modelValue" prop.

System Info

No response

Any additional comments?

No response

avatar
Jun 26th 2023

https://github.com/vuejs/core/issues/8465 duplicate question cc @edison1105