You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a component that uses generics and takes a bindable prop that looks like this:
{
current: T;
default: T;
error: string | null;
}
This worked fine until I upgraded, now it shows errors in both Neovim and VSCode and also in svelte-check. It still works the same but every time the component is used it shows an error: Type '{ current: unknown; default: unknown; error: string | null; }' is not assignable to type '{ current: number; default: number; error: null; }'. Types of property 'current' are incompatible. Type 'unknown' is not assignable to type 'number'.
svelte-check didn't show the error until i ran this upgrade:
but the error still shows up in Neovim/Code even before the upgrade, so I don't think the problem is in svelte-check itself, which is why I'm creating the issue here.
Reproduction
I have not been able to reproduce this in the REPL but it's not a lot of code.
The component:
This reverts commit 8c080cf.
This reverts #2477. Sadly, the idea didn't work out, as shown by two opened bug reports:
- #2506: A type union can be narrowed on the input, but not on the way back out
- #2494: A generic nested within a bound value is not properly resolved and not falling back to `any` (in #2477 we thought of the generic case, but only for when the generic is the whole value type, not when it's nested)
For these reasons I don't see a way to properly implement #1392 at the moment.
Describe the bug
I have a component that uses generics and takes a bindable prop that looks like this:
This worked fine until I upgraded, now it shows errors in both Neovim and VSCode and also in svelte-check. It still works the same but every time the component is used it shows an error:
Type '{ current: unknown; default: unknown; error: string | null; }' is not assignable to type '{ current: number; default: number; error: null; }'. Types of property 'current' are incompatible. Type 'unknown' is not assignable to type 'number'.
svelte-check didn't show the error until i ran this upgrade:
but the error still shows up in Neovim/Code even before the upgrade, so I don't think the problem is in svelte-check itself, which is why I'm creating the issue here.
Reproduction
I have not been able to reproduce this in the REPL but it's not a lot of code.
The component:
then use normally
It works if you don't bind it, or if you pass in
{x as typeof x}
, which is weirdLogs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: