Prettier 1.13.5
Playground link
Input:
const value = condition ? (nullableValue ?? fallbackValue) : nonNullableValue;
Output:
const value = condition ? nullableValue ?? fallbackValue : nonNullableValue;
Expected behavior:
I think it would be better if Prettier preserved the parentheses around the arguments of the nullish coalescing operator if nested within a conditional expression:
const value = condition ? (nullableValue ?? fallbackValue) : nonNullableValue;
My concern is that the precedence of ?? isn't immediately obvious, and I think that parentheses would improve readability here.
Prettier 1.13.5
Playground link
Input:
Output:
Expected behavior:
I think it would be better if Prettier preserved the parentheses around the arguments of the nullish coalescing operator if nested within a conditional expression:
My concern is that the precedence of
??isn't immediately obvious, and I think that parentheses would improve readability here.