* add parens for nullish coalescing fix #4873 * add function * Update tests/format/js/nullish-coalescing/nullish_coalesing_operator.js Co-authored-by: fisker Cheung <lionkay@gmail.com> * update snapshot * add changelog entry * fix typo --------- Co-authored-by: fisker Cheung <lionkay@gmail.com>
415 B
415 B
Add parentheses for nullish coalescing in ternary (#16391 by @cdignam-segment)
This change adds clarity to operator precedence.
// Input
foo ? bar ?? foo : baz;
foo ?? bar ? a : b;
a ? b : foo ?? bar;
// Prettier stable
foo ? bar ?? foo : baz;
foo ?? bar ? a : b;
a ? b : foo ?? bar;
// Prettier main
foo ? (bar ?? foo) : baz;
(foo ?? bar) ? a : b;
a ? b : (foo ?? bar);