In my current project, I'm utilizing slot props. A key aspect is a generic component that accepts an Array as its input.
This is the structure of MyComponent:
<script lang="ts">
export let data: Array<any>;
</script>
<div>
<!-- some stuff ... -->
{#each data as item}
<slot {item} />
{/each}
<!-- ... and other stuff ... -->
</div>
When calling this component, it looks like this:
<script lang="ts">
let myData : Array<MyType> = ...
</script>
<MyComponent data={myData} let:item>
<li>{item.myVerySpecificField}
</MyComponent>
I'm struggling to figure out how to explicitly type the 'item' parameter as MyType. Do you have any insights on this?
Even though the current setup works fine, I'm missing compile-time checks for types.