fix(javascript): correctly handle comments in empty arrow function expressions (#6087)
parent
c085aeb152
commit
157b020de6
|
@ -60,3 +60,23 @@ Examples:
|
||||||
test(/** @type {!Array} */ (arrOrString).length);
|
test(/** @type {!Array} */ (arrOrString).length);
|
||||||
test(/** @type {!Array} */ (arrOrString).length + 1);
|
test(/** @type {!Array} */ (arrOrString).length + 1);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- JavaScript: respect parenthesis around optional chaining before await ([#6087] by [@evilebottnawi])
|
||||||
|
|
||||||
|
<!-- prettier-ignore -->
|
||||||
|
```js
|
||||||
|
// Input
|
||||||
|
async function myFunction() {
|
||||||
|
var x = (await foo.bar.blah)?.hi;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output (Prettier stable)
|
||||||
|
async function myFunction() {
|
||||||
|
var x = await foo.bar.blah?.hi;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output (Prettier master)
|
||||||
|
async function myFunction() {
|
||||||
|
var x = (await foo.bar.blah)?.hi;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
|
@ -455,6 +455,7 @@ function needsParens(path, options) {
|
||||||
case "TSAsExpression":
|
case "TSAsExpression":
|
||||||
case "TSNonNullExpression":
|
case "TSNonNullExpression":
|
||||||
case "BindExpression":
|
case "BindExpression":
|
||||||
|
case "OptionalMemberExpression":
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case "MemberExpression":
|
case "MemberExpression":
|
||||||
|
|
|
@ -33,6 +33,10 @@ a?.b[3].c?.(x).d.e?.f[3].g?.(y).h;
|
||||||
(list || list2)?.length;
|
(list || list2)?.length;
|
||||||
(list || list2)?.[(list || list2)];
|
(list || list2)?.[(list || list2)];
|
||||||
|
|
||||||
|
async function HelloWorld() {
|
||||||
|
var x = (await foo.bar.blah)?.hi;
|
||||||
|
}
|
||||||
|
|
||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
var street = user.address?.street;
|
var street = user.address?.street;
|
||||||
var fooValue = myForm.querySelector("input[name=foo]")?.value;
|
var fooValue = myForm.querySelector("input[name=foo]")?.value;
|
||||||
|
@ -61,5 +65,9 @@ a?.b?.c.d?.e;
|
||||||
(list || list2)?.length;
|
(list || list2)?.length;
|
||||||
(list || list2)?.[list || list2];
|
(list || list2)?.[list || list2];
|
||||||
|
|
||||||
|
async function HelloWorld() {
|
||||||
|
var x = (await foo.bar.blah)?.hi;
|
||||||
|
}
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -24,3 +24,7 @@ a?.b[3].c?.(x).d.e?.f[3].g?.(y).h;
|
||||||
|
|
||||||
(list || list2)?.length;
|
(list || list2)?.length;
|
||||||
(list || list2)?.[(list || list2)];
|
(list || list2)?.[(list || list2)];
|
||||||
|
|
||||||
|
async function HelloWorld() {
|
||||||
|
var x = (await foo.bar.blah)?.hi;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue