Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svelte 5: weird typescript behavior with component bind: attribute #2515

Closed
KilDesu opened this issue Sep 25, 2024 · 2 comments
Closed

Svelte 5: weird typescript behavior with component bind: attribute #2515

KilDesu opened this issue Sep 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@KilDesu
Copy link

KilDesu commented Sep 25, 2024

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 prop value: T and a variable let variable = $state("hello").
If you try to bind:value={variable}, you get an error stating that Type 'string | number' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. even though if you hover over value in bind:value={variable} show that value has the type string.

Reproduction

Easy reproduction:

  • Clone this repo
  • Open the src/routes/+page.svelte file

More complex reproduction with additional error positioning bug:

  • Clone this repo
  • Checkout to the qlayout-refactors branch
  • Open the src/routes/dev/+page.svelte file

Expected behaviour

No eslint errors

System Info

  • OS: MacOS and Windows
  • IDE: VSCode

Which package is the issue about?

No response

Additional Information, eg. Screenshots

error message
inferred type of the value prop

It gets even worse for more complex projects, the errors are not well positioned:
weird error positioning

@KilDesu KilDesu added the bug Something isn't working label Sep 25, 2024
@dummdidumm
Copy link
Member

Probably related to #2494 / #2506 which are already fixed, release pending

@dummdidumm
Copy link
Member

Closing as this is likely fixed in the latest version, please ping if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants