Skip to content

Conversation

@poteto
Copy link
Member

@poteto poteto commented Mar 12, 2025

Extracting portions of #32416 for easier review. This PR dedupes @babel/types to resolve to 7.26.3, for compatibility in the root workspace where eslint-plugin-react-hooks resides.

I also needed to update @babel/preset-typescript in snap.

The compiler changes in HIR and ReactiveScopes were needed due to types changing. Notably, Babel added support for optional chaining assignment (currently Stage 1), so in the latest versions of @babel/types, AssignmentExpression.left can now also be of t.OptionalMemberExpression.

Given that this is in Stage 1, the compiler probably shouldn't support this syntax, so this PR updates HIR to bailout with a TODO if there is a non LVal on the lhs of an Assignment Expression.

There was also a small superficial SourceLocation change needed in InferReactiveScopeVariables as Babel 8 changes were accidentally released in 7. It doesn't affect our analysis so it seems fine to just update with the new properties.


Stack created with Sapling. Best reviewed with ReviewStack.

Co-authored-by: michael faith michaelfaith@users.noreply.github.com

@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Mar 12, 2025
Extracting portions of #32416 for easier review. This PR dedupes @babel/types to resolve to 7.26.3, for compatibility in the root workspace where eslint-plugin-react-hooks resides.

I also needed to update @babel/preset-typescript in snap.

The compiler changes in HIR and ReactiveScopes were needed due to types changing. Notably, Babel [added support for optional chaining assignment](babel/babel#15751) (currently [Stage 1](https://github.com/tc39/proposal-optional-chaining-assignment)), so in the latest versions of @babel/types, AssignmentExpression.left can now also be of t.OptionalMemberExpression.

Given that this is in Stage 1, the compiler probably shouldn't support this syntax, so this PR updates HIR to bailout with a TODO if there is a non LVal on the lhs of an Assignment Expression.

There was also a small superficial SourceLocation change needed in `InferReactiveScopeVariables` as Babel 8 changes were [accidentally released in 7](babel/babel#10746 (comment)). It doesn't affect our analysis so it seems fine to just update with the new properties.

Co-authored-by: michael faith <michaelfaith@users.noreply.github.com>
Copy link
Contributor

@mofeiZ mofeiZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@poteto poteto merged commit 4ab827b into main Mar 12, 2025
34 checks passed
@poteto poteto deleted the pr32581 branch March 12, 2025 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants