esprima icon indicating copy to clipboard operation
esprima copied to clipboard

Feature request: Optional chaining operator

Open Rosuav opened this issue 2 years ago • 9 comments

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.

Rosuav avatar Mar 18 '22 11:03 Rosuav

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.

jmelvin avatar Apr 22 '22 19:04 jmelvin

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

sergey-v9 avatar Apr 22 '22 21:04 sergey-v9

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? 57dc451e6d5dc9d692697561e402d532c9f432d0 and as far as i know the proposal passed

mariocampacci avatar May 03 '22 09:05 mariocampacci

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

jogibear9988 avatar May 05 '22 21:05 jogibear9988

Does that work with the Python bindings?

Rosuav avatar May 06 '22 01:05 Rosuav

don't know

jogibear9988 avatar May 06 '22 06:05 jogibear9988

Object deconstruction like ... not support

lmh-justdo avatar Dec 09 '22 03:12 lmh-justdo

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.

Nefcanto avatar Jun 20 '23 06:06 Nefcanto

@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)

sergey-v9 avatar Jun 20 '23 14:06 sergey-v9