A
A
Alexey Nikolaev2021-05-05 13:08:39
typescript
Alexey Nikolaev, 2021-05-05 13:08:39

How to type the returned component in Vue?

Good day.
I'm using Vue 3 + TS. There is a dynamic component and a function that returns multiple components.

currentComponent () {
   if (someCondition) return componentA;
   return componentB;
}

Components are defined via "defineComponent". I'm looking for a way to type the return value of the "currentComponent" function, but oddly enough I can't find it yet. So far, I decided to use a banal enum, but I would like a common abstract type for all components.
type AvailableComponents = typeof componentA | typeof componentB;
// хочется что-то вроде
type AvailableComponents = VueComponent

How to do it?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question