PiotrDabkowski / Js2Py

JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python🚀 Try it online:
http://piter.io/projects/js2py
MIT License
2.47k stars 261 forks source link

Optional chaining (?.) is not supported. #286

Open seyyedaliayati opened 2 years ago

seyyedaliayati commented 2 years ago

Consider the following code snippet from Mozilla Web Docs:

const adventurer = {
  name: 'Alice',
  cat: {
    name: 'Dinah'
  }
};

const dogName = adventurer.dog?.name;
console.log(dogName);
// expected output: undefined

console.log(adventurer.someNonExistentMethod?.());
// expected output: undefined

This syntax is not supported by js2py. I got the following error message when parsing:

js2py.internals.simplex.JsException: SyntaxError: Line 9: Unexpected token .