File tree Expand file tree Collapse file tree 3 files changed +66
-0
lines changed
compiler/packages/babel-plugin-react-compiler/src
__tests__/fixtures/compiler Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -2847,6 +2847,21 @@ function isReorderableExpression(
28472847 allowLocalIdentifiers ,
28482848 ) ;
28492849 }
2850+ case 'LogicalExpression' : {
2851+ const logical = expr as NodePath < t . LogicalExpression > ;
2852+ return (
2853+ isReorderableExpression (
2854+ builder ,
2855+ logical . get ( 'left' ) ,
2856+ allowLocalIdentifiers ,
2857+ ) &&
2858+ isReorderableExpression (
2859+ builder ,
2860+ logical . get ( 'right' ) ,
2861+ allowLocalIdentifiers ,
2862+ )
2863+ ) ;
2864+ }
28502865 case 'ConditionalExpression' : {
28512866 const conditional = expr as NodePath < t . ConditionalExpression > ;
28522867 return (
Original file line number Diff line number Diff line change 1+
2+ ## Input
3+
4+ ``` javascript
5+ // @flow
6+
7+ const foo = undefined ;
8+
9+ component C (... {scope = foo ?? null }: any) {
10+ return scope;
11+ }
12+
13+ export const FIXTURE_ENTRYPOINT = {
14+ fn: C ,
15+ params: [{scope: undefined }],
16+ };
17+
18+ ` ` `
19+
20+ ## Code
21+
22+ ` ` ` javascript
23+ const foo = undefined ;
24+
25+ function C (t0 ) {
26+ const { scope: t1 } = t0;
27+ const scope = t1 === undefined ? (foo ?? null ) : t1;
28+ return scope;
29+ }
30+
31+ export const FIXTURE_ENTRYPOINT = {
32+ fn: C ,
33+ params: [{ scope: undefined }],
34+ };
35+
36+ ` ` `
37+
38+ ### Eval output
39+ (kind: ok) null
Original file line number Diff line number Diff line change 1+ //@flow
2+
3+ const foo = undefined ;
4+
5+ component C ( ...{ scope = foo ?? null } : any ) {
6+ return scope ;
7+ }
8+
9+ export const FIXTURE_ENTRYPOINT = {
10+ fn : C ,
11+ params : [ { scope : undefined } ] ,
12+ } ;
You can’t perform that action at this time.
0 commit comments