-
-
Notifications
You must be signed in to change notification settings - Fork 473
Open
Labels
Description
Vue - Official extension or vue-tsc version
2.2.0
VSCode version
1.96.2
Vue version
3.5.13
TypeScript version
5.6.3
System Info
System:
OS: Linux 6.12 Arch Linux
CPU: (16) x64 AMD Ryzen 9 PRO 7940HS w/ Radeon 780M Graphics
Memory: 29.42 GB / 54.70 GB
Container: Yes
Shell: 5.2.37 - /bin/bash
Binaries:
Node: 20.17.0 - /run/user/1000/fnm_multishells/3839_1736234935335/bin/node
Yarn: 4.6.0 - /run/user/1000/fnm_multishells/3839_1736234935335/bin/yarn
npm: 10.8.2 - /run/user/1000/fnm_multishells/3839_1736234935335/bin/npm
Watchman: 20240414.112832.0 - /usr/bin/watchman
Browsers:
Chromium: 131.0.6778.204
package.json dependencies
No response
Steps to reproduce
Since I've upgrade from vue-tsc 2.1.10 to 2.2.0 it stopped inferring emit parameters whenever I am using withDefaults
with union props:
DISCLAIMER: withDefaults
+ union props is already heavily broken and I already had to use the following workaround:
const saneProps = computed<typeof props>(() => {
if ('contextId' in props && props.contextId == null) {
const { contextId, ...rest } = props
return rest as typeof props
} else if ('contextId' in props && props.requestId == null) {
const { requestId, ...rest } = props
return rest as typeof props
} else {
throwError('If this gets triggered vue fixed withDefaults and saneProps can be removed')
}
})
The reason is that withDefaults
sets the union props to undefined
even if you don't provide them in withDefaults
's second parameter, thus breaking 'contextId' in props
/'requestId' in props
(which always returns true for both).
I've linked a repro but it doesn't work on the playground, so you should copy/paste the code locally.
What is expected?
Correctly infers emit param types
What is actually happening?
Doesn't infer emit param types
Link to minimal reproduction
Any additional comments?
No response