-
Notifications
You must be signed in to change notification settings - Fork 50k
[compiler] Check TSAsExpression and TSNonNullExpression reorderability #33788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[compiler] Check TSAsExpression and TSNonNullExpression reorderability #33788
Conversation
josephsavona
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! The changes make sense. A small nit on the test fixture. It would be nice to change this (lest someone say "but there's a test fixture that uses it, it must be allowed!"), but we can land as-is if you like.
| @@ -0,0 +1,8 @@ | |||
| export const Component = ({theme = localStorage.getItem('theme')!}) => { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's just an example, but localStorage is a mutable data source that isn't safe to read from in a component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @josephsavona. I ammended my commit to remove the localStorage usage from the fixture. I was struggling to come up with a contrived example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome thanks!
…lity The TSAsExpression and TSNonNullExpression nodes are supported by `lowerExpression()` but `isReorderableExpression()` does not check if they can be reordered.
4fdc852 to
46e9417
Compare
|
Thanks again, @henryqdineen! |
#33788) ## Summary The `TSAsExpression` and `TSNonNullExpression` nodes are supported by `lowerExpression()` but `isReorderableExpression()` does not check if they can be reordered. This PR updates `isReorderableExpression()` to handle these two node types by adding cases that fall through to the existing `TypeCastExpression` case. We ran `react-compiler-healthcheck` at scale on several of our repos and found dozens of `` (BuildHIR::node.lowerReorderableExpression) Expression type `TSAsExpression` cannot be safely reordered`` errors and a handful for `TSNonNullExpression`. ## How did you test this change? In this case I added two fixture tests DiffTrain build for [fe81314](fe81314)
#33788) ## Summary The `TSAsExpression` and `TSNonNullExpression` nodes are supported by `lowerExpression()` but `isReorderableExpression()` does not check if they can be reordered. This PR updates `isReorderableExpression()` to handle these two node types by adding cases that fall through to the existing `TypeCastExpression` case. We ran `react-compiler-healthcheck` at scale on several of our repos and found dozens of `` (BuildHIR::node.lowerReorderableExpression) Expression type `TSAsExpression` cannot be safely reordered`` errors and a handful for `TSNonNullExpression`. ## How did you test this change? In this case I added two fixture tests DiffTrain build for [fe81314](fe81314)
facebook#33788) ## Summary The `TSAsExpression` and `TSNonNullExpression` nodes are supported by `lowerExpression()` but `isReorderableExpression()` does not check if they can be reordered. This PR updates `isReorderableExpression()` to handle these two node types by adding cases that fall through to the existing `TypeCastExpression` case. We ran `react-compiler-healthcheck` at scale on several of our repos and found dozens of `` (BuildHIR::node.lowerReorderableExpression) Expression type `TSAsExpression` cannot be safely reordered`` errors and a handful for `TSNonNullExpression`. ## How did you test this change? In this case I added two fixture tests DiffTrain build for [fe81314](facebook@fe81314)
facebook#33788) ## Summary The `TSAsExpression` and `TSNonNullExpression` nodes are supported by `lowerExpression()` but `isReorderableExpression()` does not check if they can be reordered. This PR updates `isReorderableExpression()` to handle these two node types by adding cases that fall through to the existing `TypeCastExpression` case. We ran `react-compiler-healthcheck` at scale on several of our repos and found dozens of `` (BuildHIR::node.lowerReorderableExpression) Expression type `TSAsExpression` cannot be safely reordered`` errors and a handful for `TSNonNullExpression`. ## How did you test this change? In this case I added two fixture tests DiffTrain build for [fe81314](facebook@fe81314)
Summary
The
TSAsExpressionandTSNonNullExpressionnodes are supported bylowerExpression()butisReorderableExpression()does not check if they can be reordered. This PR updatesisReorderableExpression()to handle these two node types by adding cases that fall through to the existingTypeCastExpressioncase.We ran
react-compiler-healthcheckat scale on several of our repos and found dozens of(BuildHIR::node.lowerReorderableExpression) Expression type `TSAsExpression` cannot be safely reorderederrors and a handful forTSNonNullExpression.How did you test this change?
In this case I added two fixture tests