Subscribe on changes!

Generic Component vs defineExpose

avatar
Sep 12th 2023

Vue version

3.3.4

Link to minimal reproduction

https://play.vuejs.org/#__DEV__eNq1Vclu2zAQ/RVWlzhALCFITq6Spi2CNj2kQWugF10UaSQrEReQlOPC0L93SGphZDvxpQcvnOXN8obDbfBZiHDdQLAIYpXJSmiiQDeC1Ckrr5JAqyS4TlhFBZeabImEgrSkkJySE3Q7GVTfgIGssq+cik4dRp7MxDj5OFjfc9YpB+NR1NsmLONMaVKOMJwB0+TKpBHrvwJ44Qe+np1OfP5UenWH55RlsET7ztUX7cPxgNiQ1oH4Y97WK2FFwzJdcUY0L8savkOag5ydkm3CyE4t4TqtG/gUOlsDMNhMc99nuie7XbM2YXHkyEUq8aCBijrVgCdC4sdGa8z2Jqur7NlQ7qWN5Lsjcec4ctbO0+ccO4K+0/KSgFBQKi0BlXckpX1xSRC9gzEtfxcqrRXfwfMmy8HtadEuFOPDyDikOBqaFJwFbmrnNBXhk+IML4slM+kUeEcWjl4jw+k15yRYaS3UIoqynKFbDnW1liEDHTFBoxs0i2TDdEVhnnN6cxFehJdRXinti0NQdP4o+YsCiSBJcOaFiVC4BjmXwJAbw9ZxYSdufuiJ6nB4ITFDA0aBNUcE7u1NsMvw3LrZr5BWxjwJDDKOaov91govX1GVk25nSGBVg/wpzP163fW0rvnLDysrcDBgSDRbQfbsFFo2o/xJbVzaDxJs1V5xOpUl4JgY9e3ve9jg/0FJed7UHcUHlL9A8boxSTqzLw3LMW/PzqZ7Z6enYuVS3W40MNVX9SpRpXEqbTJGbLtkdXYEzEwfaslYBfbc6+5kLXur31v63TPQXQoULs1DIN96ClBpDZgGWaQZkAfJhcJ8UEj6G7cgS3Nue2u3ZYW1vCI5FBUD6xfbb7NTByu14i9u+c5MK6zGfCYbl8xOF2TNq7wPbfzcWkTvD+NpSMSFvd0IrmC2dSithR8XZxfLW54WG1fO6pys5wYVu2R+sFHbra0o7Ipu2zhanVsPb7H0kEjJ68fv7cfY4wA7sY8BwEJQPRJxzyVN6/10mPFi5ZGceEAdM2+zM2HGvoJd294l5T8R4+rqmSH7qQnaf954N30=

Steps to reproduce

In App.vue the template ref to GenericComp.vue is typed by InstanceType<typeof GenericComp> but using this I get Typescript errors.

Type '<T extends MenuItem>(__VLS_props: Props & VNodeProps & AllowedComponentProps & ComponentCustomProps, __VLS_ctx?: Pick<...> | undefined, __VLS_setup?: { ...; }) => VNode<...> & { ...; }' does not satisfy the constraint 'abstract new (...args: any) => any'.

Without using the InstanceType type I get the error

Type '<T extends MenuItem>(__VLS_props: Props & VNodeProps & AllowedComponentProps & ComponentCustomProps, __VLS_ctx?: Pick<...> | undefined, __VLS_setup?: { ...; }) => VNode<...> & { ...; }' does not satisfy the constraint 'abstract new (...args: any) => any'.

What is expected?

No typescript error.

What is actually happening?

I get a typescript error and cannot compile

System Info

No response

Any additional comments?

No response

avatar
Sep 12th 2023

duplicate of #8373