Generic components using defineComponent
#9178
Unanswered
tobiasdiez
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We can conveniently declare generic components using
<script setup lang="ts" generic="T">
andHowever, the latter method only allows to use the generic type in the render method, and not say for the slots.
For example,
is compiled to something of the form
<TArgs> (__VLS_props: { argTypes: TArgs; } ... { slots in terms of TArgs } ...
while thedefineComponent
method doesn't allow to easily share the types between the render method andslots
.This is particularly relevant for library maintainers that would like to (only) define the type of a generic component and don't want to define the component using SFC.
Beta Was this translation helpful? Give feedback.
All reactions