Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify parens printing for postfix-like expressions (#11382)
* Unify parens printing for postfix exprs: (), [...], ! * Also move template tags handling * Add tagged template test * isPostfixExpression -> hasPostfixPart
- Loading branch information
1 parent
b04ddff
commit ce6cc4e
Showing
11 changed files
with
64 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
packages/babel-generator/test/fixtures/parentheses/tagged-template-expression/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
(() => {})``; | ||
(function(){}``); | ||
(a ? b : c)``; | ||
(a ? b : c)``; | ||
|
||
function* fn() { | ||
(yield)`foo`; | ||
(yield f)`foo`; | ||
} |
7 changes: 6 additions & 1 deletion
7
packages/babel-generator/test/fixtures/parentheses/tagged-template-expression/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
(() => {})``; | ||
(function () {})``; | ||
(a ? b : c)``; | ||
(a ? b : c)``; | ||
|
||
function* fn() { | ||
(yield)`foo`; | ||
(yield f)`foo`; | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/babel-generator/test/fixtures/typescript/non-null-parentheses/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(a ? b : c)!; | ||
(a ? b : c)!.d; | ||
(a ? b : c!); | ||
(a ? b : c!).d; | ||
|
||
foo!(); | ||
foo()!; | ||
|
||
async function* f() { | ||
(yield x)!; | ||
yield x!; | ||
(yield)!; | ||
|
||
(await x)!; | ||
(await x!); | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/babel-generator/test/fixtures/typescript/non-null-parentheses/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(a ? b : c)!; | ||
(a ? b : c)!.d; | ||
a ? b : c!; | ||
(a ? b : c!).d; | ||
foo!(); | ||
foo()!; | ||
|
||
async function* f() { | ||
(yield x)!; | ||
yield x!; | ||
(yield)!; | ||
(await x)!; | ||
await x!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,5 @@ async function g() { | |
F: A, | ||
d: [] | ||
}; | ||
}, (await B)); | ||
}, await B); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,5 @@ function* g() { | |
F: A, | ||
d: [] | ||
}; | ||
}, (yield B)); | ||
}, yield B); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...throw-expressions/test/fixtures/stupid-fixture-nesting-folder/await-in-argument/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
async function test() { | ||
(function (e) { | ||
throw e; | ||
})(new Error((await 'test'))); | ||
})(new Error(await 'test')); | ||
} |
2 changes: 1 addition & 1 deletion
2
...throw-expressions/test/fixtures/stupid-fixture-nesting-folder/yield-in-argument/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
function* test() { | ||
(function (e) { | ||
throw e; | ||
})(new Error((yield 'test'))); | ||
})(new Error(yield 'test')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters