Skip to content

bug: ts rest parameters syntax (...args) not properly parsed in Svelte componentsΒ #15293

@rxliuli

Description

@rxliuli

Describe the bug

I'm trying to define an async function with rest parameters in a Svelte component using TypeScript:

<script lang="ts">
const f = async (...args: any) => {
}
</script>

Svelte's parser throws an "Unexpected token" error when trying to parse the rest parameters syntax:

Unexpected token 
https://svelte.dev/e/js_parse_error
(js_parse_error)

Reproduction

https://svelte.dev/playground/hello-world?version=5.20.0#H4sIAAAAAAAAE3WRTWvDMAyG_4owOyQQsntIArvtsEMZudU9qInSGVy5WOraUPLfh9ePrfu4ydL7SK_kk2HckqnMM3kf4BCiHyCjwSkNuSnM6DyJqZYno9Mu6VLCFFfqabcr5Z28ptwahf7K94GVWMVUppY-up2CR9401qhY01ruA4vCCA2gTNxDVpYlxo1UgDzl0LRwsmzV8my5fjy3aC1bNoVROqqpNO5pLv4xqSR6cVOq3Bv9Vftm1qonBR9wcLwRaOBBFJXqV-pDHGrR6HhTwDoET8htm53m3DLAuOdeXWA4OH17OeN1B3RU4kHut1uuPvdbxLB1QjXy1LZZagIwcgVdcY7dUH3jFhhxS0pR6q795C9ekjivoEv3Slgk3UeG7OdZfze4AHBbd-mGqz5fQQPpwleNxukLuE3BAzqFkW_YVTHD6Bi9v4P-mzOil9ug-RzMOaBAlx7z_Zev5g-1TUS9wQIAAA==

Logs

System Info

System:
    OS: macOS 15.2
    CPU: (12) arm64 Apple M2 Max
    Memory: 3.30 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - /usr/local/bin/node
    npm: 10.9.2 - /usr/local/bin/npm
    pnpm: 10.3.0 - /usr/local/bin/pnpm
    bun: 1.1.6 - ~/.bun/bin/bun
    Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 131.1.73.105
    Chrome: 133.0.6943.55
    Safari: 18.2

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions