Description
Vue version
3.5.11
Link to minimal reproduction
Steps to reproduce
The SFC Playground is a bit broken because even if you remove withDefaults
it still won't be able to infer the type if you hover on the emit with your mouse. So I suggest to copy paste the code locally: vscode will be able to infer the event type once you remove withDefaults
.
Alternatively you can try to assign the event to a function which expects a different type and run vue-tsc --build --force
.
Without withDefaults
it will complain about the mismatch:
If you leave withDefaults
it won't complain because he thinks the inferred type is any:
What is expected?
Using withDefaults
in conjuction with union props shouldn't break emits type inference.
What is actually happening?
Using withDefaults
in conjuction with union props breaks emits type inference.
While this is with withDefaults
:
System Info
System:
OS: Linux 6.10 Arch Linux
CPU: (16) x64 AMD Ryzen 9 PRO 7940HS w/ Radeon 780M Graphics
Memory: 26.39 GB / 58.64 GB
Container: Yes
Shell: 5.2.37 - /bin/bash
Binaries:
Node: 20.17.0 - /run/user/1000/fnm_multishells/57865_1728023771872/bin/node
Yarn: 4.5.0 - /run/user/1000/fnm_multishells/57865_1728023771872/bin/yarn
npm: 10.8.2 - /run/user/1000/fnm_multishells/57865_1728023771872/bin/npm
Watchman: 20240414.112832.0 - /usr/bin/watchman
Browsers:
Chromium: 129.0.6668.89
npmPackages:
vue: ^3.5.11 => 3.5.11
Any additional comments?
No response