mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Specify sourceType "module" in hir-test and playground
This was preventing the playground and fixture tests from being able to compile an ExportDefaultDeclaration
This commit is contained in:
@@ -37,6 +37,7 @@ function parseFunctions(
|
||||
try {
|
||||
const ast = parse(source, {
|
||||
plugins: ["typescript", "jsx"],
|
||||
sourceType: "module",
|
||||
});
|
||||
const items: Array<NodePath<t.FunctionDeclaration>> = [];
|
||||
traverse(ast, {
|
||||
|
||||
@@ -18,12 +18,14 @@ export default function runReactForgetBabelPlugin(
|
||||
const ast = parser.parse(text, {
|
||||
sourceFilename: file,
|
||||
plugins: ["typescript", "jsx"],
|
||||
sourceType: "module",
|
||||
});
|
||||
const result = transformFromAstSync(ast, text, {
|
||||
filename: file,
|
||||
highlightCode: false,
|
||||
retainLines: true,
|
||||
plugins: [ReactForgetBabelPlugin],
|
||||
sourceType: "module",
|
||||
});
|
||||
invariant(
|
||||
result?.code != null,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* props.b does *not* influence `a`
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentA(props) {
|
||||
const a_DEBUG = [];
|
||||
a_DEBUG.push(props.a);
|
||||
if (props.b) {
|
||||
@@ -18,7 +18,7 @@ function Component(props) {
|
||||
/**
|
||||
* props.b *does* influence `a`
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentB(props) {
|
||||
const a = [];
|
||||
a.push(props.a);
|
||||
if (props.b) {
|
||||
@@ -31,7 +31,7 @@ function Component(props) {
|
||||
/**
|
||||
* props.b *does* influence `a`, but only in a way that is never observable
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentC(props) {
|
||||
const a = [];
|
||||
a.push(props.a);
|
||||
if (props.b) {
|
||||
@@ -45,7 +45,7 @@ function Component(props) {
|
||||
/**
|
||||
* props.b *does* influence `a`
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentD(props) {
|
||||
const a = [];
|
||||
a.push(props.a);
|
||||
if (props.b) {
|
||||
@@ -64,7 +64,7 @@ function Component(props) {
|
||||
/**
|
||||
* props.b does *not* influence `a`
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentA(props) {
|
||||
const $ = React.useMemoCache();
|
||||
const c_0 = $[0] !== props.a;
|
||||
const c_1 = $[1] !== props.b;
|
||||
@@ -91,7 +91,7 @@ function Component(props) {
|
||||
/**
|
||||
* props.b *does* influence `a`
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentB(props) {
|
||||
const $ = React.useMemoCache();
|
||||
const c_0 = $[0] !== props.a;
|
||||
const c_1 = $[1] !== props.b;
|
||||
@@ -120,7 +120,7 @@ function Component(props) {
|
||||
/**
|
||||
* props.b *does* influence `a`, but only in a way that is never observable
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentC(props) {
|
||||
const $ = React.useMemoCache();
|
||||
const c_0 = $[0] !== props.a;
|
||||
const c_1 = $[1] !== props.b;
|
||||
@@ -150,7 +150,7 @@ function Component(props) {
|
||||
/**
|
||||
* props.b *does* influence `a`
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentD(props) {
|
||||
const $ = React.useMemoCache();
|
||||
const c_0 = $[0] !== props.a;
|
||||
const c_1 = $[1] !== props.b;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* props.b does *not* influence `a`
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentA(props) {
|
||||
const a_DEBUG = [];
|
||||
a_DEBUG.push(props.a);
|
||||
if (props.b) {
|
||||
@@ -14,7 +14,7 @@ function Component(props) {
|
||||
/**
|
||||
* props.b *does* influence `a`
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentB(props) {
|
||||
const a = [];
|
||||
a.push(props.a);
|
||||
if (props.b) {
|
||||
@@ -27,7 +27,7 @@ function Component(props) {
|
||||
/**
|
||||
* props.b *does* influence `a`, but only in a way that is never observable
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentC(props) {
|
||||
const a = [];
|
||||
a.push(props.a);
|
||||
if (props.b) {
|
||||
@@ -41,7 +41,7 @@ function Component(props) {
|
||||
/**
|
||||
* props.b *does* influence `a`
|
||||
*/
|
||||
function Component(props) {
|
||||
function ComponentD(props) {
|
||||
const a = [];
|
||||
a.push(props.a);
|
||||
if (props.b) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function Component(props) {
|
||||
function ComponentA(props) {
|
||||
const a = [];
|
||||
const b = [];
|
||||
if (b) {
|
||||
@@ -14,7 +14,7 @@ function Component(props) {
|
||||
return <Foo a={a} b={b} />;
|
||||
}
|
||||
|
||||
function Component(props) {
|
||||
function ComponentB(props) {
|
||||
const a = [];
|
||||
const b = [];
|
||||
if (mayMutate(b)) {
|
||||
@@ -34,7 +34,7 @@ function mayMutate() {}
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function Component(props) {
|
||||
function ComponentA(props) {
|
||||
const $ = React.useMemoCache();
|
||||
const c_0 = $[0] !== props.p0;
|
||||
const c_1 = $[1] !== props.p1;
|
||||
@@ -73,7 +73,7 @@ function Component(props) {
|
||||
return t7;
|
||||
}
|
||||
|
||||
function Component(props) {
|
||||
function ComponentB(props) {
|
||||
const $ = React.useMemoCache();
|
||||
const c_0 = $[0] !== props.p0;
|
||||
const c_1 = $[1] !== props.p1;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function Component(props) {
|
||||
function ComponentA(props) {
|
||||
const a = [];
|
||||
const b = [];
|
||||
if (b) {
|
||||
@@ -10,7 +10,7 @@ function Component(props) {
|
||||
return <Foo a={a} b={b} />;
|
||||
}
|
||||
|
||||
function Component(props) {
|
||||
function ComponentB(props) {
|
||||
const a = [];
|
||||
const b = [];
|
||||
if (mayMutate(b)) {
|
||||
|
||||
@@ -13,9 +13,6 @@ function foo([a, b], { c, d, e = "e" }, f = "f", ...args) {
|
||||
}
|
||||
}
|
||||
|
||||
with (true) {
|
||||
}
|
||||
|
||||
const g = { ...a };
|
||||
const h = [...b];
|
||||
new c(...args);
|
||||
@@ -91,191 +88,182 @@ function foo([a, b], { c, d, e = "e" }, f = "f", ...args) {
|
||||
7 | constructor() {
|
||||
8 | console.log(this.#secretSauce);
|
||||
|
||||
[ReactForget] TodoError: Unhandled statement type: WithStatement
|
||||
[ReactForget] TodoError: Handle object property spread
|
||||
10 | }
|
||||
11 |
|
||||
> 12 | with (true) {
|
||||
| ^
|
||||
13 | }
|
||||
14 |
|
||||
15 | const g = { ...a };
|
||||
|
||||
[ReactForget] TodoError: Handle object property spread
|
||||
13 | }
|
||||
14 |
|
||||
> 15 | const g = { ...a };
|
||||
> 12 | const g = { ...a };
|
||||
| ^^^^
|
||||
16 | const h = [...b];
|
||||
17 | new c(...args);
|
||||
18 | c(...args);
|
||||
13 | const h = [...b];
|
||||
14 | new c(...args);
|
||||
15 | c(...args);
|
||||
|
||||
[ReactForget] TodoError: Handle non-expression array elements
|
||||
14 |
|
||||
15 | const g = { ...a };
|
||||
> 16 | const h = [...b];
|
||||
11 |
|
||||
12 | const g = { ...a };
|
||||
> 13 | const h = [...b];
|
||||
| ^^^^
|
||||
17 | new c(...args);
|
||||
18 | c(...args);
|
||||
19 | g["e"] += 1;
|
||||
14 | new c(...args);
|
||||
15 | c(...args);
|
||||
16 | g["e"] += 1;
|
||||
|
||||
[ReactForget] TodoError: Support non-expression arguments to NewExpression
|
||||
15 | const g = { ...a };
|
||||
16 | const h = [...b];
|
||||
> 17 | new c(...args);
|
||||
12 | const g = { ...a };
|
||||
13 | const h = [...b];
|
||||
> 14 | new c(...args);
|
||||
| ^^^^^^^
|
||||
18 | c(...args);
|
||||
19 | g["e"] += 1;
|
||||
20 | const [y, ...yy] = useState(0);
|
||||
15 | c(...args);
|
||||
16 | g["e"] += 1;
|
||||
17 | const [y, ...yy] = useState(0);
|
||||
|
||||
[ReactForget] TodoError: Support non-expression arguments to CallExpression
|
||||
16 | const h = [...b];
|
||||
17 | new c(...args);
|
||||
> 18 | c(...args);
|
||||
13 | const h = [...b];
|
||||
14 | new c(...args);
|
||||
> 15 | c(...args);
|
||||
| ^^^^^^^
|
||||
19 | g["e"] += 1;
|
||||
20 | const [y, ...yy] = useState(0);
|
||||
21 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
16 | g["e"] += 1;
|
||||
17 | const [y, ...yy] = useState(0);
|
||||
18 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
|
||||
[ReactForget] TodoError: Assignment expression to dynamic properties is not yet supported
|
||||
17 | new c(...args);
|
||||
18 | c(...args);
|
||||
> 19 | g["e"] += 1;
|
||||
14 | new c(...args);
|
||||
15 | c(...args);
|
||||
> 16 | g["e"] += 1;
|
||||
| ^^^
|
||||
20 | const [y, ...yy] = useState(0);
|
||||
21 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
22 |
|
||||
17 | const [y, ...yy] = useState(0);
|
||||
18 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
19 |
|
||||
|
||||
[ReactForget] TodoError: Rest elements are not supported yet
|
||||
18 | c(...args);
|
||||
19 | g["e"] += 1;
|
||||
> 20 | const [y, ...yy] = useState(0);
|
||||
15 | c(...args);
|
||||
16 | g["e"] += 1;
|
||||
> 17 | const [y, ...yy] = useState(0);
|
||||
| ^^^^^
|
||||
21 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
22 |
|
||||
23 | <Button {...args}></Button>;
|
||||
18 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
19 |
|
||||
20 | <Button {...args}></Button>;
|
||||
|
||||
[ReactForget] TodoError: Support other lvalue types beyond identifier
|
||||
19 | g["e"] += 1;
|
||||
20 | const [y, ...yy] = useState(0);
|
||||
> 21 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
16 | g["e"] += 1;
|
||||
17 | const [y, ...yy] = useState(0);
|
||||
> 18 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
| ^^^^^^^^^
|
||||
22 |
|
||||
23 | <Button {...args}></Button>;
|
||||
24 | <Button xlink:href="localhost:3000"></Button>;
|
||||
19 |
|
||||
20 | <Button {...args}></Button>;
|
||||
21 | <Button xlink:href="localhost:3000"></Button>;
|
||||
|
||||
[ReactForget] TodoError: Rest elements are not supported yet
|
||||
19 | g["e"] += 1;
|
||||
20 | const [y, ...yy] = useState(0);
|
||||
> 21 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
16 | g["e"] += 1;
|
||||
17 | const [y, ...yy] = useState(0);
|
||||
> 18 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
| ^^^^^
|
||||
22 |
|
||||
23 | <Button {...args}></Button>;
|
||||
24 | <Button xlink:href="localhost:3000"></Button>;
|
||||
19 |
|
||||
20 | <Button {...args}></Button>;
|
||||
21 | <Button xlink:href="localhost:3000"></Button>;
|
||||
|
||||
[ReactForget] TodoError: Handle spread attributes
|
||||
21 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
22 |
|
||||
> 23 | <Button {...args}></Button>;
|
||||
18 | const { z, aa = "aa", ...zz } = useCustom();
|
||||
19 |
|
||||
> 20 | <Button {...args}></Button>;
|
||||
| ^^^^^^^^^
|
||||
24 | <Button xlink:href="localhost:3000"></Button>;
|
||||
25 | <Button haha={1}></Button>;
|
||||
26 | <Button>{/** empty */}</Button>;
|
||||
21 | <Button xlink:href="localhost:3000"></Button>;
|
||||
22 | <Button haha={1}></Button>;
|
||||
23 | <Button>{/** empty */}</Button>;
|
||||
|
||||
[ReactForget] TodoError: Handle non-identifier jsx attribute names
|
||||
22 |
|
||||
23 | <Button {...args}></Button>;
|
||||
> 24 | <Button xlink:href="localhost:3000"></Button>;
|
||||
19 |
|
||||
20 | <Button {...args}></Button>;
|
||||
> 21 | <Button xlink:href="localhost:3000"></Button>;
|
||||
| ^^^^^^^^^^
|
||||
25 | <Button haha={1}></Button>;
|
||||
26 | <Button>{/** empty */}</Button>;
|
||||
27 | <DesignSystem.Button />;
|
||||
22 | <Button haha={1}></Button>;
|
||||
23 | <Button>{/** empty */}</Button>;
|
||||
24 | <DesignSystem.Button />;
|
||||
|
||||
[ReactForget] TodoError: Handle empty expressions
|
||||
24 | <Button xlink:href="localhost:3000"></Button>;
|
||||
25 | <Button haha={1}></Button>;
|
||||
> 26 | <Button>{/** empty */}</Button>;
|
||||
21 | <Button xlink:href="localhost:3000"></Button>;
|
||||
22 | <Button haha={1}></Button>;
|
||||
> 23 | <Button>{/** empty */}</Button>;
|
||||
| ^^^^^^^^^^^^
|
||||
27 | <DesignSystem.Button />;
|
||||
28 |
|
||||
29 | const j = function bar([quz, qux], ...args) {};
|
||||
24 | <DesignSystem.Button />;
|
||||
25 |
|
||||
26 | const j = function bar([quz, qux], ...args) {};
|
||||
|
||||
[ReactForget] TodoError: Handle non-identifier tags
|
||||
25 | <Button haha={1}></Button>;
|
||||
26 | <Button>{/** empty */}</Button>;
|
||||
> 27 | <DesignSystem.Button />;
|
||||
22 | <Button haha={1}></Button>;
|
||||
23 | <Button>{/** empty */}</Button>;
|
||||
> 24 | <DesignSystem.Button />;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
28 |
|
||||
29 | const j = function bar([quz, qux], ...args) {};
|
||||
30 |
|
||||
25 |
|
||||
26 | const j = function bar([quz, qux], ...args) {};
|
||||
27 |
|
||||
|
||||
[ReactForget] TodoError: Support non-identifier params: ArrayPattern
|
||||
27 | <DesignSystem.Button />;
|
||||
28 |
|
||||
> 29 | const j = function bar([quz, qux], ...args) {};
|
||||
24 | <DesignSystem.Button />;
|
||||
25 |
|
||||
> 26 | const j = function bar([quz, qux], ...args) {};
|
||||
| ^^^^^^^^^^
|
||||
30 |
|
||||
31 | for (; i < 3; i += 1) {
|
||||
32 | x.push(i);
|
||||
27 |
|
||||
28 | for (; i < 3; i += 1) {
|
||||
29 | x.push(i);
|
||||
|
||||
[ReactForget] TodoError: Support non-identifier params: RestElement
|
||||
27 | <DesignSystem.Button />;
|
||||
28 |
|
||||
> 29 | const j = function bar([quz, qux], ...args) {};
|
||||
24 | <DesignSystem.Button />;
|
||||
25 |
|
||||
> 26 | const j = function bar([quz, qux], ...args) {};
|
||||
| ^^^^^^^
|
||||
30 |
|
||||
31 | for (; i < 3; i += 1) {
|
||||
32 | x.push(i);
|
||||
27 |
|
||||
28 | for (; i < 3; i += 1) {
|
||||
29 | x.push(i);
|
||||
|
||||
[ReactForget] TodoError: Support non-variable initialization in for
|
||||
29 | const j = function bar([quz, qux], ...args) {};
|
||||
30 |
|
||||
> 31 | for (; i < 3; i += 1) {
|
||||
26 | const j = function bar([quz, qux], ...args) {};
|
||||
27 |
|
||||
> 28 | for (; i < 3; i += 1) {
|
||||
| ^
|
||||
32 | x.push(i);
|
||||
33 | }
|
||||
34 | for (; i < 3; ) {}
|
||||
29 | x.push(i);
|
||||
30 | }
|
||||
31 | for (; i < 3; ) {}
|
||||
|
||||
[ReactForget] TodoError: Support non-variable initialization in for
|
||||
32 | x.push(i);
|
||||
33 | }
|
||||
> 34 | for (; i < 3; ) {}
|
||||
29 | x.push(i);
|
||||
30 | }
|
||||
> 31 | for (; i < 3; ) {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
35 | for (;;) {}
|
||||
36 | }
|
||||
37 |
|
||||
32 | for (;;) {}
|
||||
33 | }
|
||||
34 |
|
||||
|
||||
[ReactForget] TodoError: Handle empty for updater
|
||||
32 | x.push(i);
|
||||
33 | }
|
||||
> 34 | for (; i < 3; ) {}
|
||||
29 | x.push(i);
|
||||
30 | }
|
||||
> 31 | for (; i < 3; ) {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
35 | for (;;) {}
|
||||
36 | }
|
||||
37 |
|
||||
32 | for (;;) {}
|
||||
33 | }
|
||||
34 |
|
||||
|
||||
[ReactForget] TodoError: Support non-variable initialization in for
|
||||
33 | }
|
||||
34 | for (; i < 3; ) {}
|
||||
> 35 | for (;;) {}
|
||||
30 | }
|
||||
31 | for (; i < 3; ) {}
|
||||
> 32 | for (;;) {}
|
||||
| ^^^^^^^^^^^
|
||||
36 | }
|
||||
37 |
|
||||
33 | }
|
||||
34 |
|
||||
|
||||
[ReactForget] TodoError: Handle empty for updater
|
||||
33 | }
|
||||
34 | for (; i < 3; ) {}
|
||||
> 35 | for (;;) {}
|
||||
30 | }
|
||||
31 | for (; i < 3; ) {}
|
||||
> 32 | for (;;) {}
|
||||
| ^^^^^^^^^^^
|
||||
36 | }
|
||||
37 |
|
||||
33 | }
|
||||
34 |
|
||||
|
||||
[ReactForget] TodoError: ForStatement without test
|
||||
33 | }
|
||||
34 | for (; i < 3; ) {}
|
||||
> 35 | for (;;) {}
|
||||
30 | }
|
||||
31 | for (; i < 3; ) {}
|
||||
> 32 | for (;;) {}
|
||||
| ^^^^^^^^^^^
|
||||
36 | }
|
||||
37 |
|
||||
33 | }
|
||||
34 |
|
||||
```
|
||||
|
||||
|
||||
@@ -9,9 +9,6 @@ function foo([a, b], { c, d, e = "e" }, f = "f", ...args) {
|
||||
}
|
||||
}
|
||||
|
||||
with (true) {
|
||||
}
|
||||
|
||||
const g = { ...a };
|
||||
const h = [...b];
|
||||
new c(...args);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function foo(x, y) {
|
||||
export default function foo(x, y) {
|
||||
if (x) {
|
||||
return foo(false, y);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ function foo(x, y) {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function foo(x, y) {
|
||||
export default function foo(x, y) {
|
||||
const $ = React.useMemoCache();
|
||||
if (x) {
|
||||
const c_0 = $[0] !== y;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function foo(x, y) {
|
||||
export default function foo(x, y) {
|
||||
if (x) {
|
||||
return foo(false, y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user