[compiler][ez] Enable some sprout tests that no longer need to be disabled
Summary: As title. Better support for flow typing, bugfixes, etc fixes these ghstack-source-id: 6326653ce42b33b6c1c76a494434d133382ca80a Pull Request resolved: https://github.com/facebook/react/pull/30591
Mike Vitousek committed
Aug 12, 2024 at 12:55 UTC
0d7c12c7790c4a7315af80f8c73ac951f024f4fe
5 files changed
+62
-6
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/component-declaration-basic.flow.expect.md
+31
-1
@@ -7,8 +7,17 @@ export default component Foo(bar: number) {
7
return <Bar bar={bar} />;
8
}
9
10
+component Bar(bar: number) {
11
+ return <div>{bar}</div>;
12
+}
13
+
14
function shouldNotCompile() {}
15
16
+export const FIXTURE_ENTRYPOINT = {
17
+ fn: Foo,
18
+ params: [{bar: 42}],
19
+};
20
+
21
```
22
23
## Code
@@ -29,7 +38,28 @@ export default function Foo(t0) {
38
return t1;
39
}
40
41
+function Bar(t0) {
42
+ const $ = _c(2);
43
+ const { bar } = t0;
44
+ let t1;
45
+ if ($[0] !== bar) {
46
+ t1 = <div>{bar}</div>;
47
+ $[0] = bar;
48
+ $[1] = t1;
49
+ } else {
50
+ t1 = $[1];
51
+ }
52
+ return t1;
53
+}
54
+
55
function shouldNotCompile() {}
56
57
+export const FIXTURE_ENTRYPOINT = {
58
+ fn: Foo,
59
+ params: [{ bar: 42 }],
60
+};
61
+
62
```
35
-
\ No newline at end of file
63
+
64
+### Eval output
65
+(kind: ok) <div>42</div>
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/component-declaration-basic.flow.js
+9
@@ -3,4 +3,13 @@ export default component Foo(bar: number) {
3
return <Bar bar={bar} />;
4
}
5
6
+component Bar(bar: number) {
7
+ return <div>{bar}</div>;
8
+}
9
+
10
function shouldNotCompile() {}
11
+
12
+export const FIXTURE_ENTRYPOINT = {
13
+ fn: Foo,
14
+ params: [{bar: 42}],
15
+};
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hook-declaration-basic.flow.expect.md
+13
-1
@@ -7,6 +7,11 @@ export default hook useFoo(bar: number) {
7
return [bar];
8
}
9
10
+export const FIXTURE_ENTRYPOINT = {
11
+ fn: useFoo,
12
+ params: [42],
13
+};
14
+
15
```
16
17
## Code
@@ -26,5 +31,12 @@ export default function useFoo(bar) {
31
return t0;
32
}
33
34
+export const FIXTURE_ENTRYPOINT = {
35
+ fn: useFoo,
36
+ params: [42],
37
+};
38
+
39
```
30
-
\ No newline at end of file
40
+
41
+### Eval output
42
+(kind: ok) [42]
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hook-declaration-basic.flow.js
+5
@@ -2,3 +2,8 @@
2
export default hook useFoo(bar: number) {
3
return [bar];
4
}
5
+
6
+export const FIXTURE_ENTRYPOINT = {
7
+ fn: useFoo,
8
+ params: [42],
9
+};
compiler/packages/snap/src/SproutTodoFilter.ts
+4
-4
@@ -390,11 +390,12 @@ const skipFilter = new Set([
390
'template-literal',
391
'multi-arrow-expr-export-default-gating-test',
392
393
- // TODO: we should be able to support these
394
- 'component-declaration-basic.flow',
395
- 'hook-declaration-basic.flow',
393
+ // works, but appears differently when printing
394
+ // due to optional function argument
395
'nested-function-with-param-as-captured-dep',
396
'deeply-nested-function-expressions-with-params',
397
+
398
+ // TODO: we should be able to support these
399
'readonly-object-method-calls',
400
'readonly-object-method-calls-mutable-lambda',
401
'preserve-memo-validation/useMemo-with-refs.flow',
@@ -483,7 +484,6 @@ const skipFilter = new Set([
484
'rules-of-hooks/rules-of-hooks-69521d94fa03',
485
486
// bugs
486
- 'bug-renaming-jsx-tag-lowercase',
487
'fbt/bug-fbt-plural-multiple-function-calls',
488
'fbt/bug-fbt-plural-multiple-mixed-call-tag',
489
'bug-invalid-hoisting-functionexpr',