-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
Describe the problem
I'm trying to export component as library
<script lang="ts" generics="ItemType">
const props: Props<ItemType> = $props();
...But when I try to import this component, the type ItemType becomes unknown
The only workaround I found is this:
<script lang="ts">
const TypedMyComponent = MyComponent<string>;
const items = ['a','b']
</script>
<TypedMyComponent items={items} />It look unfriendly in my opinion, is there any better option?
Why svelte cannot infer type the same way as if component is in the same project?
Why there is nothing about exporting with generic types in the docs?
Describe the proposed solution
It would be great to use the imported component with generics the same way as the local component:
<MyComponent items={items} />Importance
would make my life easier
Metadata
Metadata
Assignees
Labels
No labels