-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Copy link
Labels
help wantedWe're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!We're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!lang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
Prettier 1.13.5
Playground link
--parser babylon
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.
j-f1, anfriis, saithis, NilSet, ricealexander and 6 more
Metadata
Metadata
Assignees
Labels
help wantedWe're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!We're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!lang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.