-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Closed as not planned
Description
Vue version
3.5.13
Link to minimal reproduction
Steps to reproduce
<script setup lang="ts>
// Error
const transformed = fn(defineEmits<{
validChange: [boolean]
}>());
// Works
const emit = defineEmits<{
validChange: [boolean]
}>();
const transformed = fn(emit);
</script>What is expected?
Using the result of defineEmits() as a function argument without assigning it to a variable first.
In my case I transform the return emit instance to individual event functions.
What is actually happening?
ReferenceError: defineEmits is not defined
setup about:srcdoc line 63 > injectedScript:20
callWithErrorHandling https://cdn.jsdelivr.net/npm/@vue/runtime-dom@3.5.13/dist/runtime-dom.esm-browser.js:2334
setupStatefulComponent https://cdn.jsdelivr.net/npm/@vue/runtime-dom@3.5.13/dist/runtime-dom.esm-browser.js:9982
setupComponent https://cdn.jsdelivr.net/npm/@vue/runtime-dom@3.5.13/dist/runtime-dom.esm-browser.js:9943
mountComponent https://cdn.jsdelivr.net/npm/@vue/runtime-dom@3.5.13/dist/runtime-dom.esm-browser.js:7293
processComponent https://cdn.jsdelivr.net/npm/@vue/runtime-dom@3.5.13/dist/runtime-dom.esm-browser.js:7259
patch https://cdn.jsdelivr.net/npm/@vue/runtime-dom@3.5.13/dist/runtime-dom.esm-browser.js:6788
render https://cdn.jsdelivr.net/npm/@vue/runtime-dom@3.5.13/dist/runtime-dom.esm-browser.js:8056
mount https://cdn.jsdelivr.net/npm/@vue/runtime-dom@3.5.13/dist/runtime-dom.esm-browser.js:6056
mount https://cdn.jsdelivr.net/npm/@vue/runtime-dom@3.5.13/dist/runtime-dom.esm-browser.js:12239
_mount about:srcdoc line 63 > injectedScript:18
<anonymous> about:srcdoc line 63 > injectedScript:23System Info
System:
OS: Windows 10 10.0.19045
CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Memory: 21.30 GB / 39.85 GB
Binaries:
Node: 22.14.0 - C:\Program Files\nodejs\node.EXE
npm: 10.3.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.11.0 - C:\Program Files\nodejs\pnpm.CMD
Browsers:
Chrome: 129.0.6668.70
Edge: Chromium (127.0.2651.105)
Internet Explorer: 11.0.19041.4355Any additional comments?
I ran into this bug when I tried to create a wrapper for defineEmits that coverts the emit function to individual functions.
const emit = defineEmits<{
validChange: [valid: boolean];
}>();
const { validChange } = useEmitters(emit); // This sadly has to be on separate line
const valid = computed(() => ...);
watch(valid, (value) => validChange(value));Metadata
Metadata
Assignees
Labels
No labels