Subscribe on changes!

defineEmits() type cannot use computed keys

avatar
Apr 5th 2023

Vue version

>= 3.3.0.alpha.7

Link to minimal reproduction

https://sfc.vuejs.org/#eNqNULtuwzAM/BVCSx6wrV11AnToL3SpOrg24yqwHhApdwj875WSDO4DRReKJ4p3uruIxxCaOaFQoqU+msBAyCnA1LnxoAWTFkftAOS+1N47YkBrGA4w4Mk4fMqA2kuZAmxRwSaFoWNU1g84PXdTwk0FczkVEEfjxp2C2ZuhrCzH7e6hNHtZ6n80fuFX8PJF4HVF3cqbr+wiA0Ybprx9Q3IFRSWMDT5ybbvQnMm7nMlVUt8HOQoF909okUMrWIt35kBKSjr1JckzNT6OMndNTI6NxQbJ1m/RfxDGTKxFteKQ+XLGWEd0A0aMf3F+e/qD9+pau0UsnwwOoOY=

Steps to reproduce

<script setup lang="ts">
  const emit = defineEmits<{
    'update:modelValue': [value: string]
  }>();
</script>

What is expected?

Should compile component without error.

What is actually happening?

Error: [@vue/compiler-sfc] defineEmits() type cannot use computed keys.

App.vue
8  |    
9  |    const emit = defineEmits<{
10 |      'update:modelValue': [value: string]
   |      ^^^^^^^^^^^^^^^^^^^
11 |    }>();
12 |  </script>

It seems bug was introduced in commit https://github.com/vuejs/core/commit/ef73ea53eaf853d43e70946d2d448ae8c0a83e4f