Skip to content

Commit cf5bcb5

Browse files
committed
[Compiler Bug] Complier mark ts instantiation expression as reorderable in build hir (#34488)
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. Before submitting a pull request, please make sure the following is done: 1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`. 2. Run `yarn` in the repository root. 3. If you've fixed a bug or added code that should be tested, add tests! 4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development. 5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`. 6. If you need a debugger, run `yarn test --debug --watch TestName`, open `chrome://inspect`, and press "Inspect". 7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`). 8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files. 9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`). 10. If you haven't already, complete the CLA. Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html --> ## Summary <!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? --> The React Compiler rejected a default parameter that contains a TSInstantiationExpression with the todo message that the expression cannot be safely reordered. This change teaches the reorder check in BuildHIR.ts to treat TSInstantiationExpression as reorderable. This is safe because TypeScript instantiation only affects types and is erased at runtime, so it has no side effects and does not change semantics. ## How did you test this change? ``` Set-Content testfilter.txt 'ts-instantiation-default-param' yarn test --filter --update yarn test --filter ``` <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. How exactly did you verify that your PR solves the issue you wanted to solve? If you leave this empty, your PR will very likely be closed. --> I added a fixture: > compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ts-instantiation-default-param.js DiffTrain build for [5813211](5813211)
1 parent 4ad8af0 commit cf5bcb5

35 files changed

+90
-86
lines changed

compiled/eslint-plugin-react-hooks/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25489,6 +25489,10 @@ function isReorderableExpression(builder, expr, allowLocalIdentifiers) {
2548925489
return true;
2549025490
}
2549125491
}
25492+
case 'TSInstantiationExpression': {
25493+
const innerExpr = expr.get('expression');
25494+
return isReorderableExpression(builder, innerExpr, allowLocalIdentifiers);
25495+
}
2549225496
case 'RegExpLiteral':
2549325497
case 'StringLiteral':
2549425498
case 'NumericLiteral':

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1bcdd224b10999138ef5aa1c1917b28d918e5421
1+
581321160fe0d9d9ef461174c7e14cbbed341d28
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1bcdd224b10999138ef5aa1c1917b28d918e5421
1+
581321160fe0d9d9ef461174c7e14cbbed341d28

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ __DEV__ &&
14191419
exports.useTransition = function () {
14201420
return resolveDispatcher().useTransition();
14211421
};
1422-
exports.version = "19.2.0-www-classic-1bcdd224-20250918";
1422+
exports.version = "19.2.0-www-classic-58132116-20250918";
14231423
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14241424
"function" ===
14251425
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ __DEV__ &&
14191419
exports.useTransition = function () {
14201420
return resolveDispatcher().useTransition();
14211421
};
1422-
exports.version = "19.2.0-www-modern-1bcdd224-20250918";
1422+
exports.version = "19.2.0-www-modern-58132116-20250918";
14231423
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14241424
"function" ===
14251425
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,4 +602,4 @@ exports.useSyncExternalStore = function (
602602
exports.useTransition = function () {
603603
return ReactSharedInternals.H.useTransition();
604604
};
605-
exports.version = "19.2.0-www-classic-1bcdd224-20250918";
605+
exports.version = "19.2.0-www-classic-58132116-20250918";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,4 +602,4 @@ exports.useSyncExternalStore = function (
602602
exports.useTransition = function () {
603603
return ReactSharedInternals.H.useTransition();
604604
};
605-
exports.version = "19.2.0-www-modern-1bcdd224-20250918";
605+
exports.version = "19.2.0-www-modern-58132116-20250918";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ exports.useSyncExternalStore = function (
606606
exports.useTransition = function () {
607607
return ReactSharedInternals.H.useTransition();
608608
};
609-
exports.version = "19.2.0-www-classic-1bcdd224-20250918";
609+
exports.version = "19.2.0-www-classic-58132116-20250918";
610610
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
611611
"function" ===
612612
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ exports.useSyncExternalStore = function (
606606
exports.useTransition = function () {
607607
return ReactSharedInternals.H.useTransition();
608608
};
609-
exports.version = "19.2.0-www-modern-1bcdd224-20250918";
609+
exports.version = "19.2.0-www-modern-58132116-20250918";
610610
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
611611
"function" ===
612612
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19860,10 +19860,10 @@ __DEV__ &&
1986019860
(function () {
1986119861
var internals = {
1986219862
bundleType: 1,
19863-
version: "19.2.0-www-classic-1bcdd224-20250918",
19863+
version: "19.2.0-www-classic-58132116-20250918",
1986419864
rendererPackageName: "react-art",
1986519865
currentDispatcherRef: ReactSharedInternals,
19866-
reconcilerVersion: "19.2.0-www-classic-1bcdd224-20250918"
19866+
reconcilerVersion: "19.2.0-www-classic-58132116-20250918"
1986719867
};
1986819868
internals.overrideHookState = overrideHookState;
1986919869
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19897,7 +19897,7 @@ __DEV__ &&
1989719897
exports.Shape = Shape;
1989819898
exports.Surface = Surface;
1989919899
exports.Text = Text;
19900-
exports.version = "19.2.0-www-classic-1bcdd224-20250918";
19900+
exports.version = "19.2.0-www-classic-58132116-20250918";
1990119901
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1990219902
"function" ===
1990319903
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)