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

Feature request: Optional chaining operator #2112

Open
Rosuav opened this issue Mar 18, 2022 · 9 comments
Open

Feature request: Optional chaining operator #2112

Rosuav opened this issue Mar 18, 2022 · 9 comments

Comments

@Rosuav
Copy link

Rosuav commented Mar 18, 2022

Steps to reproduce

esprima.parse('foo?.bar')

Expected output

Some indication that this is optional chaining (if foo exists, it's the same as foo.bar, else it's undefined)

Actual output

"Unexpected token ."

Relevant references

https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#prod-OptionalExpression

This is supported in all major browsers and Node.js.

@jmelvin
Copy link

jmelvin commented Apr 22, 2022

We started using more ES6 syntax recently and also ran into the optional chaining failure. It guess we will have to be more selective until this is supported.

@sergey-v9
Copy link

we have had to move to nightly-esprima because of this

@mariocampacci
Copy link

it is not implemented (?)
although it seems limited to template literal as suggested by the comment

however I cannot understend why: ES6 shouldn't be handled? 57dc451
and as far as i know the proposal passed

@jogibear9988
Copy link

you can also try my esprima fork esprima-next
wich is in es6 and should work with ES6 code
https://github.com/node-projects/esprima-next

@Rosuav
Copy link
Author

Rosuav commented May 6, 2022

Does that work with the Python bindings?

@jogibear9988
Copy link

don't know

@lmh-justdo
Copy link

Object deconstruction like ... not support

@Nefcanto
Copy link

we have had to move to nightly-esprima because of this

@sergey-v9 what is that nightly-esprima? I searched it and it takes me back to the esprima repository itself.

@sergey-v9
Copy link

@Nefcanto yes, it is the same, but bult from the latest version of the code in this repo from 2021 year (while the official last version was 4.0.1 from 2018 year)

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

7 participants