Skip to content

Svelte 5.43.0+: Function bindings and await in a single component cause an error #17092

@Serator

Description

@Serator

Describe the bug

The following code causes an error:

<script lang="ts">
  const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms))
  const test = await delay(1000)// <<< ❌ causes an error
  let width = $state(0)
  const updateWidth = (value: DOMRectReadOnly) => (width = value.width)
</script>

<div bind:contentRect={null, updateWidth}></div>
{width}
Image

Reproduction

Logs

System Info

-

Severity

annoyance

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