dillon1000/react
Commit
Browse files [patch][babel] check babel identifier before lowering to HoistedConst
Same babel identifier issue as #2510 but for HoistedConst
Not sure how we should best test this -- one possibility is using constant prop.
Currently, we have false positives for HoistedConst that prevent constant
propagation. I don't want to over-rotate on babel apis tests in our fixtures
(instead of semantically interesting ones)
```js
// input
function Component() {
{ x: 4 };
const x = 2;
return x;
}
// output
function Component() {
const $ = useMemoCache(1);
let x;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
x = 2;
$[0] = x;
} else {
x = $[0];
}
return x;
}
```Changed paths6 files
First-parent comparisoncompiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts ModifiedD compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-destructuring-same-property-identifier-names.expect.md DeletedD compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-destructuring-same-property-identifier-names.js DeletedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-same-property-identifier-names.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-same-property-identifier-names.js AddedM compiler/packages/sprout/src/SproutTodoFilter.ts ModifiedPatch
Files changed
Rendering syntax-highlighted changes…