dillon1000/react
Commit
Browse files [ez] Add TODO bailout on non-backward compatible holey arrays
--- (pasted from comment) Instead of handling holey arrays, bail out with a TODO error. Older versions of babel seem to have inconsistent handling of holey arrays, at least when paired with HermesParser. When using these versions, we should bail out instead of throwing a Babel validation error. Issue: The babel ast definition for array elements changed from Array<PatternLike> to Array<PatternLike | null>. Older versions do not expect null in the ArrayPattern ast and will throw a validation error during Codegen. - HermesParser will parse [, b] into [NodePath<null>, NodePath<Identifier>] - Forget will try to preserve this holey array when we codegen back to js (e.g. we call a babel builder function arrayPattern([null, identifier])) - Babel will fail with `TypeError: Property elements[0] of ArrayPattern expected node to be of a type ["PatternLike"] but instead got null` PR that changed the AST definition: https://github.com/babel/babel/pull/10917/files#diff-19b555d2f3904c206af406540d9df200b1e16befedb83ff39ebfcbd876f7fa8aL52-R56 [ez] Add TODO bailout on non-backward compatible holey arrays --- (pasted from comment) Instead of handling holey arrays, bail out with a TODO error. Older versions of babel seem to have inconsistent handling of holey arrays, at least when paired with HermesParser. When using these versions, we should bail out instead of throwing a Babel validation error. Issue: The babel ast definition for array elements changed from Array<PatternLike> to Array<PatternLike | null>. Older versions do not expect null in the ArrayPattern ast and will throw a validation error during Codegen. - HermesParser will parse [, b] into [NodePath<null>, NodePath<Identifier>] - Forget will try to preserve this holey array when we codegen back to js (e.g. we call a babel builder function arrayPattern([null, identifier])) - Babel will fail with `TypeError: Property elements[0] of ArrayPattern expected node to be of a type ["PatternLike"] but instead got null` PR that changed the AST definition: https://github.com/babel/babel/pull/10917/files#diff-19b555d2f3904c206af406540d9df200b1e16befedb83ff39ebfcbd876f7fa8aL52-R56
Changed paths5 files
First-parent comparisoncompiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts ModifiedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.backwards-compatible-holey-arrays.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.backwards-compatible-holey-arrays.js AddedM compiler/packages/fixture-test-utils/src/compiler-utils.ts ModifiedPatch
Files changed
Rendering syntax-highlighted changes…