Implicit generic type on slot children #13846
Replies: 2 comments
|
I don't think this is currently something Vue's type system can infer automatically. The generic parameter for In other words, these are inferred independently: <DataTable<T>>
<DataTableColumn<U>>There isn't currently a mechanism that says "infer That's why Unfortunately, I don't think Possible alternatives
I believe this is more of a current limitation of Vue's language tooling (Volar / |
|
Uh oh!
There was an error while loading. Please reload this page.
Hi, I have a parent/child pair of generic components (
DataTable<T>andDataTableColumn<T>) where I want to tie the type parameter together implicitly when the child is used in a slot, like so:where DataTable looks like:
and DataTableColumn is:
I want the type of
rowto be inferred from the type of:dataso I can get proper typechecking in templates for usage of the row type.I saw #8015 and it seems like a similar use case, but the best I figured out was to put
<!-- @vue-generic {MyArrayElementType} -->before each DataTableColumn definition which is pretty unfortunate. I've also tried changing thedefineSlots()definition to have return types other thananyto no success.I'm using Vue 3.5.13 and vue-tsc 2.2.2.
Is there a way to infer the type through automatically?
All reactions