-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
TypeScript 5.4 aggressive union type narrowing breaks svelte-check #2316
Comments
Just ran into this. This fails for me: <script lang="ts">
let period: 'monthly' | 'yearly' = 'yearly'
</script>
{#if period === 'monthly'}
paid every month
{/if} With this error:
EDIT: To temporarily work around this issue, I changed the typescript dependency to: |
You can cast the string 'yearly' as 'monthly' | 'yearly' to get around it for now if you wanna stay on 5.4.x.
|
This one is expected because there isn't any reassignment. If your actual case has an assignment somewhere that isn't binding. Can you share it here? |
@dummdidumm Sadly, this is not completely fixed in the latest svelte-check v3.6.8. Maybe it's missing a special case for If you run |
Describe the bug
TypeScript's new type narrowing behavior is causing svelte-check to emit
This comparison appears to be unintentional because the types '...' and '...' have no overlap.
on a variable when its value is mutated via binding.Note this change is only currently affecting top-level variables. Union types also include boolean and enum types.
Reproduction
Expected behaviour
svelte-check should pass with no errors. Since bound expressions are type checked as covariant to the prop's type, the target variable's effective type ought to be widened to the entire union type.
System Info
svelte-check 3.6.7
Which package is the issue about?
svelte-check
Additional Information, eg. Screenshots
No response
The text was updated successfully, but these errors were encountered: