Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap object expressions in parentheses if they become children of an …
…arrow function expression (#3540)
- Loading branch information
1 parent
c445d60
commit 1ca18a3
Showing
3 changed files
with
15 additions
and
1 deletion.
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
9 changes: 9 additions & 0 deletions
9
test/function/samples/simplify-arrow-expression-with-object/_config.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,9 @@ | ||
const assert = require('assert'); | ||
|
||
module.exports = { | ||
description: 'correctly simplifies arrow expressions where the right hand side becomes an object', | ||
exports(exports) { | ||
assert.deepStrictEqual(exports.conditional(), { x: 42, y: 43 }); | ||
assert.deepStrictEqual(exports.logical(), { x: 42, y: 43 }); | ||
} | ||
}; |
2 changes: 2 additions & 0 deletions
2
test/function/samples/simplify-arrow-expression-with-object/main.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,2 @@ | ||
export const logical = () => true && { x: 42, y: 43, }; | ||
export const conditional = () => true ? { x: 42, y: 43, } : null; |