mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
--- (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