dillon1000/react

Commit

feat(compiler): implement constant folding for unary minus (#33140)

## Summary
`-constant` is represented as a `UnaryExpression` node that is currently
not part of constant folding. If the operand is a constant number, the
node is folded to `constant * -1`. This also coerces `-0` to `0`,
resulting in `0 === -0` being folded to `true`.

## How did you test this change?
See attached tests
Browse files
Changed paths4 files
First-parent comparison
M compiler/packages/babel-plugin-react-compiler/src/Optimization/ConstantPropagation.ts ModifiedA compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constant-propagation-unary-number.expect.md AddedA compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constant-propagation-unary-number.js AddedM compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constant-propagation-unary.expect.md Modified
Patch

Files changed

Rendering syntax-highlighted changes…