From 5dd5393cc770ac15a9c2452fe37316cf88c69a9d Mon Sep 17 00:00:00 2001 From: Ives van Hoorne Date: Tue, 14 Jul 2020 15:43:08 +0200 Subject: [PATCH 1/2] initial commit --- src/astring.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/astring.js b/src/astring.js index 6c01e96f..817bbf9d 100644 --- a/src/astring.js +++ b/src/astring.js @@ -818,7 +818,7 @@ export const baseGenerator = { UnaryExpression(node, state) { if (node.prefix) { state.write(node.operator) - if (node.operator.length > 1) { + if (node.operator.length > 1 || node.argument.type === 'UnaryExpression') { state.write(' ') } if ( From 04adc25c03edbfd75d453a233f0652d3df814068 Mon Sep 17 00:00:00 2001 From: David Bonnet Date: Sat, 2 Jan 2021 09:48:44 +0100 Subject: [PATCH 2/2] Add non-regression tests --- src/tests/fixtures/syntax/precedence.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tests/fixtures/syntax/precedence.js b/src/tests/fixtures/syntax/precedence.js index 08312f35..2d6d7fbd 100644 --- a/src/tests/fixtures/syntax/precedence.js +++ b/src/tests/fixtures/syntax/precedence.js @@ -14,7 +14,7 @@ a = !false; b = !x instanceof Number; c = !(x instanceof Number); d = typeof a === 'boolean'; -e = !typeof a === 'boolean'; +e = ! typeof a === 'boolean'; f = !(typeof a === 'boolean'); a = (1.1).toString(); b = new A().toString(); @@ -29,3 +29,5 @@ e = 2 ** +3; f = a + (b = 3); g = 1 && (() => {}); g = (() => {}) && 1; +g = (1, + +2); +g = (1, + +(2 + 3));