Issue with Spread Operator Inside JSON
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.1k
- Forks
- 773
- PR merge metrics
- No merged PRs in 30d
Description
When trying to parse a JSON expression containing a spread operator, we get an error, even though the code is valid.
Steps to reproduce
Try to validate the below code:
var x = {
a: "asdf",
b: "qwerty",
...(1 > 0 ? { c: "zxcv" } : ""),
d: 1234
};
Expected output
A message saying "Code is syntactically valid."
Actual output
Error: Line 4: Unexpected token ...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied object-spread example with Esprima's validator and confirm the reported unexpected-token error. The issue is done when this expression is accepted as syntactically valid and produces the expected validation message without an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100