[tests] bug repros
Mofei Zhang committed
Aug 26, 2023 at 14:00 UTC
6dbc48075b6feba902533bd41b69ac1a9df7f933
5 files changed
+93
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-lambda-return-expression.expect.md
new
+28
@@ -0,0 +1,28 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+import { invoke } from "shared-runtime";
6
+
7
+function useFoo() {
8
+ const x = {};
9
+ const result = invoke(() => x);
10
+ console.log(result);
11
+}
12
+
13
+export const FIXTURE_ENTRYPOINT = {
14
+ fn: useFoo,
15
+ params: [],
16
+ isComponent: false,
17
+};
18
+
19
+```
20
+
21
+
22
+## Error
23
+
24
+```
25
+[ReactForget] Invariant: Expected value for identifier `16` to be initialized. (5:5)
26
+```
27
+
28
+
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-lambda-return-expression.ts
new
+13
@@ -0,0 +1,13 @@
1
+import { invoke } from "shared-runtime";
2
+
3
+function useFoo() {
4
+ const x = {};
5
+ const result = invoke(() => x);
6
+ console.log(result);
7
+}
8
+
9
+export const FIXTURE_ENTRYPOINT = {
10
+ fn: useFoo,
11
+ params: [],
12
+ isComponent: false,
13
+};
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-validate-identifiers-object-key.expect.md
new
+36
@@ -0,0 +1,36 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+function Foo() {
6
+ return {
7
+ "a.b": 1,
8
+ "a\b": 2,
9
+ "a/b": 3,
10
+ "a+b": 4,
11
+ "a b": 5,
12
+ };
13
+}
14
+
15
+export const FIXTURE_ENTRYPOINT = {
16
+ fn: Foo,
17
+ params: [],
18
+ isComponent: false,
19
+};
20
+
21
+```
22
+
23
+
24
+## Error
25
+
26
+```
27
+Unexpected token, expected "," (2:13)
28
+ 1 | import { unstable_useMemoCache as useMemoCache } from "react";function Foo() {const $ = useMemoCache(1);let t0;if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
29
+> 2 | t0 = { a.b: 1, a: 2, a/b: 3, a+b: 4, a b: 5 };$[0] = t0;} else {t0 = $[0];}return t0;}
30
+ | ^
31
+ 3 |
32
+ 4 |
33
+ 5 |
34
+```
35
+
36
+
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-validate-identifiers-object-key.ts
new
+15
@@ -0,0 +1,15 @@
1
+function Foo() {
2
+ return {
3
+ "a.b": 1,
4
+ "a\b": 2,
5
+ "a/b": 3,
6
+ "a+b": 4,
7
+ "a b": 5,
8
+ };
9
+}
10
+
11
+export const FIXTURE_ENTRYPOINT = {
12
+ fn: Foo,
13
+ params: [],
14
+ isComponent: false,
15
+};
compiler/packages/snap/src/compiler-worker.ts
+1
@@ -88,6 +88,7 @@ export async function compile(
88
runReactForgetBabelPlugin
89
).code;
90
} catch (e) {
91
+ e.message = e.message.replace(/\u001b[^m]*m/g, '');
92
error = e;
93
}
94