mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
[compiler] Fix broken tests
ghstack-source-id: 000a37ae1f819eef676dcd52410d5231cd2d50fe Pull Request resolved: https://github.com/facebook/react/pull/31078
This commit is contained in:
+21
-17
@@ -19,15 +19,17 @@ function Component() {
|
||||
);
|
||||
}
|
||||
|
||||
function cx(obj) {
|
||||
const classes = [];
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value) {
|
||||
classes.push(key);
|
||||
const cx = {
|
||||
foo(obj) {
|
||||
const classes = [];
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value) {
|
||||
classes.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
return classes.join(' ');
|
||||
}
|
||||
return classes.join(' ');
|
||||
},
|
||||
};
|
||||
|
||||
function useTheme() {
|
||||
return {
|
||||
@@ -71,15 +73,17 @@ function Component() {
|
||||
return t1;
|
||||
}
|
||||
|
||||
function cx(obj) {
|
||||
const classes = [];
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value) {
|
||||
classes.push(key);
|
||||
const cx = {
|
||||
foo(obj) {
|
||||
const classes = [];
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value) {
|
||||
classes.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
return classes.join(" ");
|
||||
}
|
||||
return classes.join(" ");
|
||||
},
|
||||
};
|
||||
|
||||
function useTheme() {
|
||||
return {
|
||||
@@ -97,4 +101,4 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```
|
||||
|
||||
### Eval output
|
||||
(kind: exception) cx.foo is not a function
|
||||
(kind: ok) <div class="styles/light styles/dark"></div>
|
||||
+10
-8
@@ -15,15 +15,17 @@ function Component() {
|
||||
);
|
||||
}
|
||||
|
||||
function cx(obj) {
|
||||
const classes = [];
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value) {
|
||||
classes.push(key);
|
||||
const cx = {
|
||||
foo(obj) {
|
||||
const classes = [];
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value) {
|
||||
classes.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
return classes.join(' ');
|
||||
}
|
||||
return classes.join(' ');
|
||||
},
|
||||
};
|
||||
|
||||
function useTheme() {
|
||||
return {
|
||||
|
||||
+5
-1
@@ -4,6 +4,8 @@
|
||||
```javascript
|
||||
import {CONST_TRUE, identity, shallowCopy} from 'shared-runtime';
|
||||
|
||||
function mutate(_: unknown) {}
|
||||
|
||||
/**
|
||||
* There are three values with their own scopes in this fixture.
|
||||
* - arr, whose mutable range extends to the `mutate(...)` call
|
||||
@@ -45,6 +47,8 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { CONST_TRUE, identity, shallowCopy } from "shared-runtime";
|
||||
|
||||
function mutate(_) {}
|
||||
|
||||
/**
|
||||
* There are three values with their own scopes in this fixture.
|
||||
* - arr, whose mutable range extends to the `mutate(...)` call
|
||||
@@ -91,4 +95,4 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```
|
||||
|
||||
### Eval output
|
||||
(kind: exception) mutate is not defined
|
||||
(kind: ok)
|
||||
+2
@@ -1,5 +1,7 @@
|
||||
import {CONST_TRUE, identity, shallowCopy} from 'shared-runtime';
|
||||
|
||||
function mutate(_: unknown) {}
|
||||
|
||||
/**
|
||||
* There are three values with their own scopes in this fixture.
|
||||
* - arr, whose mutable range extends to the `mutate(...)` call
|
||||
|
||||
+5
-1
@@ -6,6 +6,8 @@
|
||||
import {useCallback} from 'react';
|
||||
import {identity, useIdentity} from 'shared-runtime';
|
||||
|
||||
function mutate(_: unknown) {}
|
||||
|
||||
/**
|
||||
* Repro showing a manual memo whose declaration (useCallback's 1st argument)
|
||||
* is memoized, but not its dependency (x). In this case, `x`'s scope is pruned
|
||||
@@ -33,6 +35,8 @@ import { c as _c } from "react/compiler-runtime"; // @validatePreserveExistingMe
|
||||
import { useCallback } from "react";
|
||||
import { identity, useIdentity } from "shared-runtime";
|
||||
|
||||
function mutate(_) {}
|
||||
|
||||
/**
|
||||
* Repro showing a manual memo whose declaration (useCallback's 1st argument)
|
||||
* is memoized, but not its dependency (x). In this case, `x`'s scope is pruned
|
||||
@@ -62,4 +66,4 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```
|
||||
|
||||
### Eval output
|
||||
(kind: exception) mutate is not defined
|
||||
(kind: ok) "[[ function params=0 ]]"
|
||||
+2
@@ -2,6 +2,8 @@
|
||||
import {useCallback} from 'react';
|
||||
import {identity, useIdentity} from 'shared-runtime';
|
||||
|
||||
function mutate(_: unknown) {}
|
||||
|
||||
/**
|
||||
* Repro showing a manual memo whose declaration (useCallback's 1st argument)
|
||||
* is memoized, but not its dependency (x). In this case, `x`'s scope is pruned
|
||||
|
||||
+5
-1
@@ -4,6 +4,8 @@
|
||||
```javascript
|
||||
import {identity, makeObject_Primitives} from 'shared-runtime';
|
||||
|
||||
function useHook() {}
|
||||
|
||||
function useTest({cond}) {
|
||||
const val = makeObject_Primitives();
|
||||
|
||||
@@ -31,6 +33,8 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { identity, makeObject_Primitives } from "shared-runtime";
|
||||
|
||||
function useHook() {}
|
||||
|
||||
function useTest(t0) {
|
||||
const $ = _c(3);
|
||||
const { cond } = t0;
|
||||
@@ -64,4 +68,4 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```
|
||||
|
||||
### Eval output
|
||||
(kind: exception) useHook is not defined
|
||||
(kind: ok) {"a":0,"b":"value1","c":true}
|
||||
+2
@@ -1,5 +1,7 @@
|
||||
import {identity, makeObject_Primitives} from 'shared-runtime';
|
||||
|
||||
function useHook() {}
|
||||
|
||||
function useTest({cond}) {
|
||||
const val = makeObject_Primitives();
|
||||
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
import {makeObject_Primitives} from 'shared-runtime';
|
||||
import {makeObject_Primitives, Stringify} from 'shared-runtime';
|
||||
|
||||
function Component(props) {
|
||||
let useFeature = makeObject_Primitives();
|
||||
@@ -32,7 +32,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { makeObject_Primitives } from "shared-runtime";
|
||||
import { makeObject_Primitives, Stringify } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
const $ = _c(2);
|
||||
@@ -75,4 +75,4 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```
|
||||
|
||||
### Eval output
|
||||
(kind: exception) Stringify is not defined
|
||||
(kind: ok) <div>{"val":{"a":0,"b":"value1","c":true},"children":[2,"[[ cyclic ref *1 ]]",null]}</div>
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import {makeObject_Primitives} from 'shared-runtime';
|
||||
import {makeObject_Primitives, Stringify} from 'shared-runtime';
|
||||
|
||||
function Component(props) {
|
||||
let useFeature = makeObject_Primitives();
|
||||
|
||||
Reference in New Issue
Block a user