No support for optional chaining syntax
See original GitHub issueWhat is your Scenario?
I have a site which loads a code with the following line
this._pageLabels?.[this._currentPageNumber - 1] ?? null;
HH transforms it to the
__get$(this._pageLabels,this._currentPageNumber-1) ?? null;
and this code throws an error during runtime
Uncaught (in promise) Error: Cannot read property '0' of null at Function.t._error (hammerhead.js:12) at value (hammerhead.js:12)
The logic in transformed code is different.
I managed to get it working by extending createPropertyGetWrapper / createComputedPropertyGetWrapper with optional flag and changing the logic of method but I don’t know if this is a correct solution.
The site is an internal one so I cannot share the url
What is the Current behavior?
HH transformed code with optional chaining syntax have the different logic than the original one
What is the Expected behavior?
HH should detect optional chaining and perform a proper transformation
What is your public website URL? (or attach your complete example)
Private
What is your TestCafe test code?
I’ve been using proxy
Your complete configuration file
No response
Your complete test report
No response
Screenshots
No response
Steps to Reproduce
- Find a site with optional chaining code
- Try to use proxy on the site
- Site code breaks
TestCafe version
testcafe-hammerhead 24.2.1
Node.js version
No response
Command-line arguments
Browser name(s) and version(s)
No response
Platform(s) and version(s)
No response
Other
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:29 (8 by maintainers)
Top GitHub Comments
We intend to fix the bug as soon as possible, so I would recommend that you wait for the fix.
Hi guys! I take TC version 1.18.6, that uses testcafe-hammerhead": “24.5.18” and the problem is still present: I get the following code d=(t&&t[“function.from”])??null converted to d=t&&t[“function.from”]??null that leads to Uncaught SyntaxError: Unexpected token ‘??’