Subscribe on changes!

make an export of ComponentPublicInstanceConstructor type into runtime-core.d.ts

avatar
Oct 7th 2022

What problem does this feature solve?

our team use this type to declare component props and we have to use patch for that

What does the proposed API look like?

-declare type ComponentPublicInstanceConstructor +export declare type ComponentPublicInstanceConstructor

avatar
Oct 7th 2022

Most of the time, types are not exposed for a reason. What are you trying to achieve that isn't achievable otherwise? Have you checked the types of defineComponent() and other exposed types of vue? They should be enough

avatar
Oct 7th 2022

Have you checked the types of defineComponent() and other exposed types of vue? They should be enough

it ain't enough unfortunately.

In our case we use some function which lazy loads any component with some props or emits and in this way Eslint correctly shows wrong props end emits of used component.

Like this showPopup({ component: () => import('SomePopup.vue'), someProp: 'propValue', otherProp: 'propValue2' })

Function const showPopup = <T extends Component>(options: PopupOptions<T>) => { ... }

Declare types type PopupOptions<T extends Component> = { component: AsyncComponentLoader<T> } & ComponentProps<T>; type ComponentProps<T extends Component> = T extends ComponentPublicInstanceConstructor<infer P> ? P['$props'] & P['$emits'] : Record<string, any>;