You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
constsaneProps=computed<typeofprops>(()=>{if('contextId'inprops&&props.contextId==null){const{ contextId, ...rest}=propsreturnrestastypeofprops}elseif('contextId'inprops&&props.requestId==null){const{ requestId, ...rest}=propsreturnrestastypeofprops}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.
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
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:The reason is that
withDefaults
sets the union props toundefined
even if you don't provide them inwithDefaults
'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
https://play.vuejs.org/#eNqNU01z0zAQ/Ss7OtB0pmMf4JRxAwUCEw7QAW6Ig2tvXBVZEvpIwhT/966kxEmaTqe+2Nrdp3373vqeXRlTrAKyKatcY4Xx4NAHA7JW3SVn3nE240r0RlsPn4R1HpZW93BWlOkUwWdcVWVGUy0dPPZG1h7pBFBllMW/AZ1ftHRrzRmUlKzKg0p2Qd0arZaiK+6cVkTpPuI5a3RvhET7zXihFTGaQsrEXC2lXn9JMW8DXuzizS02f56I37lNjHF2bdGhXSFnY87XtkOf0/MfX3FD32Oy122QVP1M8js6LUPkmMveB9US7YO6xHaRxBSq++nmG4/K7YaKRGPlkOo5I2k/PDP6nu7r4k3CcTWQihHzAk9bXAqF8154V6U767adwi9BllATqKfgvCWWMPyme2eT8yOXH3ncitXsqirj69TWcVFetmWR/7hku2Fox7haC3/7EZd1kN5NYt88w7XVxlVZlq06AJ3VwSzat7sxcnyAV5CQ8fm/r44P7Z4nWxekggr9DRk3JknZJyHjUh93OYCQagAkXrJ0i91SiytS3zScbb07FvhE4qhExr8jp+Jf5P6pBiYK15/jhedwOYsz0A5iIXW3T+QOpz/c8ADATkw/
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: