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

Missing Spreadoperator compliance in dict #2129

Open
Anton3210 opened this issue Nov 29, 2024 · 4 comments
Open

Missing Spreadoperator compliance in dict #2129

Anton3210 opened this issue Nov 29, 2024 · 4 comments

Comments

@Anton3210
Copy link

Running a dict containing a Spreadoperator gives an error:

babel/parser.parse() on this :
const a = {'a':'b','b':'b','c':'c'};
const b = {'z':'z'};
const y = {...a,...b};

gives Following error:

Error: Line 3: Unexpected token ...
at ErrorHandler.constructError (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:5012:22)
at ErrorHandler.createError (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:5028:27)
at Parser.unexpectedTokenError (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:1985:39)
at Parser.throwUnexpectedToken (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:1995:21)
at Parser.parseObjectPropertyKey (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2499:33)
at Parser.parseObjectProperty (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2534:25)
at Parser.parseObjectInitializer (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2602:35)
at Parser.inheritCoverGrammar (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2285:37)
at Parser.parsePrimaryExpression (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2354:38)
at Parser.inheritCoverGrammar (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2285:37) {
index: 69,
lineNumber: 3,
description: 'Unexpected token ...'
}

@mmiscool
Copy link

mmiscool commented Dec 3, 2024

I am getting the same error.
Is this library still being maintained at all?

@Meir017
Copy link
Contributor

Meir017 commented Dec 3, 2024

@Anton3210
Copy link
Author

I´m using acorn now

import * as acorn_walk from 'acorn-walk';
import { ancestor } from 'acorn-walk';
function findNodeByValue(ast, value) {
let path = [];
let callback = function(){}
let functionBase = {...acorn_walk.base};
functionBase.Literal = function(node,_state,ancestor){
count++;
if (node.value==value) {
path.push({"node":node,"ancestor":ancestor})
}
}
acorn_walk.fullAncestor(ast,function(a,b,c){},functionBase
);//node, callback, baseVisitor, state, override

return path;

}
ast = acorn.parse(strings,{
// parse in strict mode and allow module declarations
sourceType: "script",
ecmaVersion : 12,

plugins: [
// enable jsx and flow syntax
"jsx",
"flow",
],
})

@mmiscool
Copy link

mmiscool commented Dec 5, 2024

@mmiscool try here https://github.com/node-projects/esprima-next

This package worked perfectly for me. Thanks for pointing it out.

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

No branches or pull requests

3 participants