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

unexpected token error for "export let value = getContext('value') || (v) => v;" #4384

Closed
hamilton opened this issue Feb 7, 2020 · 2 comments · Fixed by #4385
Closed

unexpected token error for "export let value = getContext('value') || (v) => v;" #4384

hamilton opened this issue Feb 7, 2020 · 2 comments · Fixed by #4385
Labels

Comments

@hamilton
Copy link

hamilton commented Feb 7, 2020

Describe the bug

I am updating a large Svelte codebase from 3.12.1 to 3.18.1, and received a parsing error for the following line that previously worked fine:

export let value = getContext('value') || (v) => v;

If I replace the arrow function with something like function myFunction(v) { return v} the error goes away.

To Reproduce

https://svelte.dev/repl/60c49c4243014a69acfc47b79437ae7e?version=3.18.1 reproduces the issue minimally.

Expected behavior
The pattern export let myFunc = getContext('myFunc') || (v) => v; should not cause any kind of error.

Stacktraces
If you have a stack trace to include, we recommend putting inside a <details> block for the sake of the thread's readability:

Stack trace
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
13: export let tickFormatter = getContext('tickFormatter') || ((v) => v);

Information about your Svelte project:

  • Your browser and the version: Firefox 73.0b9 (64-bit)

  • Your operating system: OS X 10.14

  • Svelte version 3.18.1

  • Whether your project uses Webpack or Rollup

Severity

This is not blocking my team at the moment, since we have a workaround by using function myFunction(v) { return v }; in place of the arrow function but I could see this throwing others off and eroding trust in Svelte.

@Conduitry
Copy link
Member

Opened Rich-Harris/code-red#31 for underlying code generation issue.

@Conduitry
Copy link
Member

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