Skip to content

Svelte 5: Snippet argument doesn't support a default parameter #9770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Not-Jayden opened this issue Dec 5, 2023 · 2 comments
Closed

Svelte 5: Snippet argument doesn't support a default parameter #9770

Not-Jayden opened this issue Dec 5, 2023 · 2 comments

Comments

@Not-Jayden
Copy link
Contributor

Not-Jayden commented Dec 5, 2023

Describe the bug

I would expect you would be able to default a snippet parameter like you can when writing a regular function, however the parser doesn't currently handle that case.

<script>
	import Box from './Box.svelte';
</script>

<Box>
	{#snippet children(data = {foo: 'foo', bar: 'bar'})}
		{data.foo} {data.bar}
	{/snippet}
</Box>

Reproduction

REPL

Logs

CompileError: Expected token )
    at ar (compiler.cjs@5.0.0-next.18:1:228313)
    at qn.eat (compiler.cjs@5.0.0-next.18:1:290576)
    at eval (compiler.cjs@5.0.0-next.18:1:281813)
    at Pn (compiler.cjs@5.0.0-next.18:1:282074)
    at new qn (compiler.cjs@5.0.0-next.18:1:286529)
    at Ln (compiler.cjs@5.0.0-next.18:1:292001)
    at e.compile (compiler.cjs@5.0.0-next.18:1:640150)
    at Object.transform (index-a870eda6.js:74:3556)
    at index-a870eda6.js:55:31298
yy @ index-a870eda6.js:83
await in yy (async)
(anonymous) @ index-a870eda6.js:74
setTimeout (async)
(anonymous) @ index-a870eda6.js:74

System Info

REPL chrome

Severity

annoyance

@Not-Jayden
Copy link
Contributor Author

Might make sense to wait for #9672 to be implemented first before actioning (if it is being implemented)

@dummdidumm
Copy link
Member

Default parameters are now supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants