Skip to content
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

Reserved work used in prop default value outputs invalid javascript #3929

Closed
TerryRPatterson opened this issue Nov 15, 2019 · 2 comments · Fixed by #3931
Closed

Reserved work used in prop default value outputs invalid javascript #3929

TerryRPatterson opened this issue Nov 15, 2019 · 2 comments · Fixed by #3931
Assignees
Labels

Comments

@TerryRPatterson
Copy link

Describe the bug
When giving a prop a default value of an object that uses a keyword as both key, and value (i.e {true : true}) the svelte compiler outputs invalid JavaScript, {true}.

To Reproduce
https://svelte.dev/repl/2edabca108b64bcb909791bf1c5f58fa?version=3.14.1

Expected behavior
Svelte will not collapse object literal declarations into the short form for keywords.

Information about your Svelte project:
This issue affects version 3.13.0 and up.

Severity
It is slightly annoying as I had to move the default into a separate variable for now, but not blocking in anyway.

@Conduitry Conduitry added the bug label Nov 15, 2019
@Conduitry
Copy link
Member

Conduitry commented Nov 15, 2019

Thanks for the report! I guess Rich-Harris/code-red#9 didn't cover all of what we needed here. Presumably we also need to check whether the value is an identifier.

@TerryRPatterson
Copy link
Author

Awesome, Thank you for the quick fix!
And thank y'all for making svelte I love using it.

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

Successfully merging a pull request may close this issue.

2 participants