Exponential operator in if condition is not transpiled
See original GitHub issueOriginal source code:
if (2 ** 3 > 0) { alert('test'); }
Expected transpiled code:
0 < Math.pow(2, 3) && alert("test");
0 < 2 ** 3 && alert("test");
Same result in ternary operator.
Also, it throws an error in Advanced Optimization.
JSC_INTERNAL_ERROR_UNEXPECTED_TOKEN: Internal Error: TypeCheck doesn't know how to handle EXPONENT at line 1 character 4
if (2 ** 3 > 0) { alert('test'); }
^
If another exponential operator is in body, they are transpiled. Original:
if (2 ** 3 > 0) { alert(2 ** 3); }
Transpiled:
0 < Math.pow(2, 3) && alert(Math.pow(2, 3));
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Use the Exponentiation Operator in JavaScript - Egghead.io
ES2016 introduced the exponentiation operator ** to JavaScript. This lesson shows how it works and how you can use it as a replacement...
Read more >Exponentiation (**) - JavaScript - MDN Web Docs - Mozilla
The exponentiation (**) operator returns the result of raising the first operand to the power of the second operand.
Read more >The Exponentiation Operator in JavaScript - Marius Schulz
#The Exponentiation Operator in Babel Similarly, the exponentiation operator can be transpiled by Babel as well. By default, however, Babel ...
Read more >CoffeeScript
CoffeeScript can compile if statements into JavaScript expressions, using the ternary operator when possible, and closure wrapping otherwise. There is no ...
Read more >Webpack and Babel not transpiling a dependency inside ...
Ok, it turns out to process files inside node_modules you need to use babel.config.js rather than .babelrc as explained here and here:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@teppeis I’ve reproduced this in the unit test. I’m debugging it now.
@MatrixFrog @brad4d thanks!