Skip to content

Unexpected token when using snippet with type annotations without script lang='ts' tag #16835

@lazy-student217

Description

@lazy-student217

Describe the bug

In Vite + Svelte 5, snippets with type annotations without script lang='ts', like the following

{#snippet bar(text: string)} {text} {/snippet} 

would trigger a unexpected token error, even with typescript support.

I am unsure that if there is a simliar issue opened for this problem (i am sorry if i overlooked), and also if this is the expected behavior. If error is expected, we should have a better error messages instead of a confusing 'unexpected token'.

Reproduction

Using the code:

{#snippet bar(text: string)} {text} {/snippet} 

with a proper typescript support.

Logs

None.

System Info

System: OS: Linux 6.16 Arch Linux CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900HK Memory: 9.09 GB / 15.34 GB Container: Yes Shell: 5.3.3 - /bin/bash Binaries: Node: 24.8.0 - /usr/bin/node pnpm: 10.17.0 - /usr/bin/pnpm npmPackages: svelte: ^5.39.5 => 5.39.5

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    PRs welcomewe're not going to spend any time on this, but we'll accept pull requests

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions