Skip to content

bind:value={fn, fn} expects incorrect types #15623

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

Open
gyzerok opened this issue Mar 27, 2025 · 2 comments
Open

bind:value={fn, fn} expects incorrect types #15623

gyzerok opened this issue Mar 27, 2025 · 2 comments

Comments

@gyzerok
Copy link

gyzerok commented Mar 27, 2025

Describe the bug

It seems like Svelte is using type inference for binds which ends up with incorrect typings.

In practice for <input type="number" /> the values are of type number | null, but it shows string in the following example.

Image

This ends up with runtime errors down the road.

Reproduction

REPL

Logs

System Info

Svelte 5.25.3, TypeScript 5.8.2

Severity

annoyance

@gyzerok gyzerok changed the title bind:value={fn, fn} gives incorrect types bind:value={fn, fn} expects incorrect types Mar 28, 2025
@dummdidumm
Copy link
Member

This is a limitation of the type system. Even if we were to be able to make it related to the input type better, it would be any at best, because it's impossible to type that for type=number the value type is different than for type=text

@gyzerok
Copy link
Author

gyzerok commented Apr 1, 2025

@dummdidumm got it, but this leaves me wondering if it is a good idea than to transform values for number input to numbers behind the scenes. In my case I wasn't expecting this at all and discovered the issue after looking at a strange runtime crashes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants