Skip to content

destructuring {#each} with fallback has type inference error #14766

@cloudymeatball

Description

@cloudymeatball

Describe the bug

From svelte@5.13.0, destructuring {#each} with default fallbacks leads to Cannot find name 'variableName'.

Reproduction

In svelte@5.12.0, we could do something like this

<script lang=ts>
  let arr = [['123'], ['456', '789']]
</script>
{#each arr as [key, value = 'default']}
  <div>{key}: {value}</div>
{/each}

But in 5.13.0 the same code has typescript errors
Cannot find name 'key', Cannot find name 'value', ',' expected.

Logs

No response

System Info

svelte@^5.13.0, typescript@^5 with either vite5 or vite6, with or without the corresponding @sveltejs/vite-plugin-svelte.

Severity

blocking an upgrade

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions