dillon1000/react
Commit
Browse files compiler: error on reassigning to const
We currently don't report an error if the code attempts to reassign a const. Our thinking has been that we're not trying to catch all possible mistakes you could make in JavaScript — that's what ESLint, TypeScript, and Flow are for — and that we want to focus on React errors. However, accidentally reassigning a const is easy to catch and doesn't get in the way of other analysis so let's implement it. Note that React Compiler's ESLint plugin won't report these errors by default, but they will show up in playground. Fixes #29598 ghstack-source-id: a0af8b9a486d74a8991413322efddc3e3028c755 Pull Request resolved: https://github.com/facebook/react/pull/29619
Changed paths5 files
First-parent comparisoncompiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts ModifiedM compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts ModifiedM compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts ModifiedA compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-reassign-const.expect.md AddedA compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-reassign-const.js AddedPatch
Files changed
Rendering syntax-highlighted changes…