Subscribe on changes!

type-only emits / Typed defineEmits - Unsupported computed key in type referenced by a macro

avatar
May 22nd 2023

Vue version

3.3.4 (latest)

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-qeqqu8?file=src%2Fcomponents%2FHelloWorld.vue

Steps to reproduce

Let the build on stackblitz run, see the error.

What is expected?

No errors and a working build

What is actually happening?

Error after Build:

11:55:11 [vite] Internal server error: [@vue/compiler-sfc] Unsupported computed key in type referenced by a macro

/home/projects/vitejs-vite-qeqqu8/src/components/HelloWorld.vue
4  |  
5  |  defineEmits<{
6  |    [GREAT_NAME]: [];
   |     ^^^^^^^^^^
7  |  }>();
8  | 

System Info

System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.92 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.n/bin/node
    npm: 9.6.6 - ~/tmp/node_modules/.bin/npm
  Browsers:
    Chrome: 113.0.5672.126
    Firefox: 112.0.2
    Safari: 16.4

Any additional comments?

We intended to test the new type support in Vue 3.3.x and encountered the following issue:

Our problem arises when utilizing type-only emits and importing the keys from another file.

avatar
May 22nd 2023

We need to use the runtime version of defineEmits and defineProps - https://github.com/vuejs/core/discussions/7927