Unexpected token when parsing a member expression after a property initializer in an object pattern
See original GitHub issueBug Report
- I would like to work on a fix!
Current Behavior A clear and concise description of the behavior.
The following snippet will throw SyntaxError: Unexpected token, expected “,” Input Code
- REPL or Repo link if applicable: REPL
({ a = 42, b: {}.d } = {})
Expected behavior/code It should parse successfully.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc): No plugin.
Environment REPL
Possible Solution
We may reset refExpressionErrors.shortAssign
when parsing Assignment Expression after eating tt.colon
in parseObjectProperty
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Eslint - `Parsing error: unexpected token =` error for assigned ...
You're using class field (a.k.a. property initializer) syntax, which is not part of ECMAScript 2015 (ES6), nor ES2016 or 2017, ...
Read more >SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >https://opensource.apple.com/source/JavaScriptCore...
do { updateErrorMessage(shouldPrintToken, __VA_ARGS__); return 0; } ... "There must be at least one bound property in an object deconstruction pattern"); auto ...
Read more >acorn.mjs - Communardo
These carry several kinds of properties to help the // parser use them properly ... If found, consume it, otherwise, // raise an...
Read more >LWC1503: Parsing error: Unexpected token
Thanks, Vijay. ... Hi Vijay, Here recordId and objectApiName is a variable and you are using it as a string value, also use...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s because chrome parses it as an expression. If you use
@babel/parser
’sparseExpression
it will work, or you have to wrap it in parentheses:({ a = 3 } = {})
.I would like to take this up. I’ve made a fork and I’m working on fixing the issue. What are next steps?