ternary operator > lambda > ternary fails to parse himself after formatting
See original GitHub issueThe following nested ternary
let icecream = what == "cone"
? p => !!p ? `here's your ${p} cone` : `just the empty cone for you`
: p => `here's your ${p} ${what}`;
gets formatted to
let icecream = what == "cone"
? p => (!!p ? `here's your ${p} cone` : `just the empty cone for you`)
: p => `here's your ${p} ${what}`;
which consequently fails a subsequent parsing with
SyntaxError: Invalid left-hand side in arrow function parameters (2:11)
;
(using prettier 1.44)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Recursion with ternary operator 'hack' in Python - Stack Overflow
import ast tree = ast.parse('lambda S,b : (g(S[1:],b),S)[len(S)==b]') ast.dump(tree). After some formatting done in vim this is what I got:
Read more >Conditional (ternary) operator - JavaScript - MDN Web Docs
The conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark (?)
Read more >Ternary Operator in Python - GeeksforGeeks
Ternary operators are also known as conditional expressions are operators that evaluate something based on a condition being true or false.
Read more >Java static code analysis: The ternary operator should not be ...
While the ternary operator is pleasingly compact, its use can make code more difficult to read. It should therefore be avoided in favor...
Read more >How to use Java's conditional operator ?: | TheServerSide
Quickly learn how to use the Java ternary operator and see how this ... after question mark, and causes a compile error: Type...
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 Free
Top 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
I have a PR ready for this, but the latest Babylon version can’t be bumped in Prettier b/c we split the TS/Flow types. I have an update ready for this as well but waiting for an upstream change in
typescript-eslint-parser
to land.Looks related to issues regarding https://github.com/babel/babylon/issues/58