diff --git a/packages/babel-generator/src/node/parentheses.js b/packages/babel-generator/src/node/parentheses.js index 0a1ab115c5..1222f2d34a 100644 --- a/packages/babel-generator/src/node/parentheses.js +++ b/packages/babel-generator/src/node/parentheses.js @@ -2,6 +2,7 @@ import * as t from "@babel/types"; const PRECEDENCE = { "||": 0, + "??": 0, "&&": 1, "|": 2, "^": 3, diff --git a/packages/babel-generator/test/fixtures/parentheses/nullish-coalescing/input.js b/packages/babel-generator/test/fixtures/parentheses/nullish-coalescing/input.js new file mode 100644 index 0000000000..2e5054151a --- /dev/null +++ b/packages/babel-generator/test/fixtures/parentheses/nullish-coalescing/input.js @@ -0,0 +1,2 @@ +const foo = 'test' +console.log((foo ?? '') == '') \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/parentheses/nullish-coalescing/output.js b/packages/babel-generator/test/fixtures/parentheses/nullish-coalescing/output.js new file mode 100644 index 0000000000..767c8f1b02 --- /dev/null +++ b/packages/babel-generator/test/fixtures/parentheses/nullish-coalescing/output.js @@ -0,0 +1,2 @@ +const foo = 'test'; +console.log((foo ?? '') == ''); \ No newline at end of file