Svelte 5: weird typescript behavior with component bind:
attribute
#2515
Labels
bug
Something isn't working
bind:
attribute
#2515
Describe the bug
After updating all packages versions, the
bind:
attribute behaves in a weird way.Let's say you have a component generic
T extends string | number
, a component propvalue: T
and a variablelet variable = $state("hello")
.If you try to
bind:value={variable}
, you get an error stating thatType 'string | number' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'.
even though if you hover overvalue
inbind:value={variable}
show thatvalue
has the typestring
.Reproduction
Easy reproduction:
src/routes/+page.svelte
fileMore complex reproduction with additional error positioning bug:
qlayout-refactors
branchsrc/routes/dev/+page.svelte
fileExpected behaviour
No eslint errors
System Info
Which package is the issue about?
No response
Additional Information, eg. Screenshots
It gets even worse for more complex projects, the errors are not well positioned:
The text was updated successfully, but these errors were encountered: