ES6 string and boolean operator and ternary produces strange result
See original GitHub issuePrettier 1.10.2 Playground link
Input:
const message =
`${originalErrorMessageString}\n` +
`${normalizedError.stack}\n` +
originalErrorStringified !== originalErrorMessageString
? `Original error: ${originalErrorStringified}`
: "";
Output:
const message =
`${originalErrorMessageString}\n` +
`${normalizedError.stack}\n` +
originalErrorStringified !==
originalErrorMessageString
? `Original error: ${originalErrorStringified}`
: "";
Expected behavior:
const message =
`${originalErrorMessageString}\n` +
`${normalizedError.stack}\n` +
originalErrorStringified !== originalErrorMessageString
? `Original error: ${originalErrorStringified}`
: "";
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Rethinking the JavaScript ternary operator - James Sinclair
With the ternary operator, the second and third expressions can be any type. But the interpreter will always cast the first to a...
Read more >Logical AND (&&) - JavaScript - MDN Web Docs
The logical AND (&&) (logical conjunction) operator for a set of boolean operands will be true if and only if all the operands...
Read more >How do you use the ? : (conditional) operator in JavaScript?
The conditional (ternary) operator is the only JavaScript operator that takes three operands. This operator is frequently used as a shortcut for the...
Read more >How the Question Mark (?) Operator Works in JavaScript
The term ternary means composed of three items or parts. The ? operator is also called the ternary operator because, unlike other operators...
Read more >Conditional branching: if, '?'
Boolean conversion. The if (…) statement evaluates the expression in its parentheses and converts the result to a boolean. Let's recall the ...
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
@j-f1 updated, missed your comment.
Can you fill out the issue template please?
You should be able to go to the playground, put in your original code, click “Report issue,” then paste the result into your issue body.