Replies: 2 comments
-
|
What I find surprising is that Tried to collapse the type using generics, but that apparently does not work either 🤔 <script lang="ts" generics="T extends string | number">
let { value = $bindable() }: {
value?: T;
} = $props();
</script> |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I see that the issue is caused by Svelte for VS Code, feat: better type checking for bindings in Svelte 5 #2477, merged 2 weeks ago. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If I have a component with a bindable prop
value: string | number | undefinedand use this component and give it avalue: stringas follows:<component bind:value />This was OK until recently, but now I get Typescript error in VS code as
string | number | undefinedcannot be bound to astring.I can fix this by with:
<component bind:value={value as string} />But this is long-winded, is bad practise (type casting) and need to be done 1000's of times.
Is there any other solution?
Beta Was this translation helpful? Give feedback.
All reactions