dillon1000/react
Commit
Browse files Detect hoisting where the reference is a reassignment
Our logic to detect hoisting relies on Babel's `isReferencedIdentifier()` to determine whether a reference to an identifier is a reference or a declaration. The idea is that we want to find references to variables that may be hoistable, before the declaration — the definition of hoisting. But due to the bug in isReferencedIdentifier, we skipped over reassignments of hoisted variables. The hack here checks if an identifier is a direct child of an AssignmentExpression, ensuring we visit reassignments.
Changed paths3 files
First-parent comparisoncompiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-function-expression-references-later-variable-declaration.expect.md ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-function-expression-references-variable-its-assigned-to.expect.md ModifiedPatch
Files changed
Rendering syntax-highlighted changes…