Skip to content

Destructuring doesn't work when using await in $derived() #16442

@edwardmanhattan

Description

@edwardmanhattan

Describe the bug

I don't know if this is a deliberate syntax design or not, but apparently, I cannot de-structure the output of my async function using $derived().

This result in an Unexpected reserved word error :
const {foo,bar} = $derived(await someAsyncFunction())

Reproduction

REPL

Logs

app.js:54 
 SyntaxError: Unexpected reserved word
handleError	@	app.js:54

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (12) x64 13th Gen Intel(R) Core(TM) i5-13420H
    Memory: 10.12 GB / 23.71 GB
  Binaries:
    Node: 20.15.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
    bun: 1.2.6 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (131.0.2903.86)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    svelte: ^5.36.7 => 5.36.7

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions