-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Open
Labels
🍰 p2-nice-to-havePriority 2: this is not breaking anything but nice to have it addressed.Priority 2: this is not breaking anything but nice to have it addressed.
Description
Vue version
3.4.27
Link to minimal reproduction
Steps to reproduce
In the official use case, when defining components using defineComponent
, an example of using generics is as follows:
const Comp = defineComponent(
<T extends string | number>(props: { msg: T; list: T[] }) => {
// use Composition API here like in <script setup>
const count = ref(0)
return () => {
// render function or JSX
return <div>{count.value}</div>
}
},
// manual runtime props declaration is currently still needed.
{
props: ['msg', 'list']
}
)
I know that generic
can be used to define in composite APIs, but child components and parent components are defined by defineComponent, so I want to know how to pass generic from the parent component in tsx###
What is expected?
like react, we can pass generics like this:
return () => {
return (
<div>
<Comp<{ name: string }> msg="hello" list={list.value} />
</div>)
}
What is actually happening?
I couldn't find any way to pass generics into child components,like this
System Info
No response
Any additional comments?
No response
Metadata
Metadata
Assignees
Labels
🍰 p2-nice-to-havePriority 2: this is not breaking anything but nice to have it addressed.Priority 2: this is not breaking anything but nice to have it addressed.