-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
Description
Describe the bug
The bug is simple, if the useElementSize
is used with templateRef
that targets Vue Component, and that component emits, then TypeScript will fail:
types of property '$emit' are incompatible.
Type '(event: "mounted", ...args: any[]) => void' is not assignable to type '(event: string, ...args: any[]) => void'.
Types of parameters 'event' and 'event' are incompatible.
Type 'string' is not assignable to type '"mounted"'.
This happens regardless if emit
is consumed by parent or not, and regardless of which defineEmits
syntax we're using.
I've also found this issue with useFocusWithin
, so all functions taking MaybeElement
might be affected.
Reproduction
https://stackblitz.com/edit/stackblitz-starters-jqvqqvmh
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@vueuse/core: ^13.9.0 => 13.9.0
vue: ^3.5.22 => 3.5.22
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a VueUse issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.