Skip to content

TypeScript 5.4 aggressive union type narrowing breaks svelte-check #2316

@AaronAtP123

Description

@AaronAtP123

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

<script lang="ts">let checked = true;</script>
<input type="checkbox" bind:checked />
{#if checked === false}false{/if}

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

  • OS: Windows 10
  • IDE: VSCode

Which package is the issue about?

svelte-check

Additional Information, eg. Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions