Skip to content

fix: allow parenthesized assignment target in arrow initializer - #18442

Merged
nicolo-ribaudo merged 3 commits into
7.xfrom
automation/backport-18372
Oct 29, 2026
Merged

nicolo-ribaudo merged 3 commits into
7.xfrom
automation/backport-18372

Conversation

@babel-bot

Copy link
Copy Markdown
Collaborator

Backport of #18372 to 7.x

Cherry-picked commits:

Conflicts: Resolved.

  • packages/babel-parser/src/parser/statement.ts: parseFunction differs on 7.x (function expression ids are parsed without the tokenIsIdentifier guard and expression scope wrapper). Kept the 7.x code; only the sharedExpressionScope / parameterDeclarationScope renames are applied.
  • packages/babel-parser/src/util/expression-scope.ts: 7.x uses Position locations (origin, loc.index) instead of numeric offsets. Applied the !scope.isInitializer() boundary logic in recordParameterInitializerError and validateAsPattern using the 7.x variables.

Fix commits:

  • Fix TS type names after backporting #18372: the new tsIsTypeCast helper used N.TSAsExpression etc.; on 7.x the types are named N.TsAsExpression, N.TsSatisfiesExpression, N.TsNonNullExpression, N.TsTypeAssertion, which broke tscheck.
  • Regenerate parser fixtures for 7.x AST after backporting #18372: regenerated 4 new fixtures' output.json (with OVERWRITE=true) whose expected output used the Babel 8 AST (e.g. TSMappedType.key/constraint, no TSParenthesizedType, TSTypeParameter.name as Identifier, no extra.shorthand).

Checks:

  • rebuild: passed.
  • lint: tscheck passes and prettier passes on changed files. check-compat-data could not run (needs network to clone compat-table) and ESLint could not run in the sandbox (missing jiti), so neither was verified.
  • test: full Jest suite run. All backport-related tests pass. The only remaining failure is packages/babel-code-frame/test/color-detection.js, which is environment-related (terminal color detection) and unrelated to this PR.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"

See Network Configuration for more information.

Generated by 🔙 Backport to 7.x for #18372 · copilot · auto · 42.3 AIC · ⌖ 0.867 AIC · ⊞ 9.1K · ◷

@babel-bot

Copy link
Copy Markdown
Collaborator Author

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/62674

@nicolo-ribaudo nicolo-ribaudo assigned Copilot and unassigned Copilot Oct 29, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: 78a0e0b

@nicolo-ribaudo nicolo-ribaudo changed the title fix(parser): allow parenthesized assignment target in arrow initializer fix: allow parenthesized assignment target in arrow initializer Oct 29, 2026
@nicolo-ribaudo
nicolo-ribaudo merged commit 941a136 into 7.x Oct 29, 2026
119 checks passed
@nicolo-ribaudo
nicolo-ribaudo deleted the automation/backport-18372 branch October 29, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.x: backport pkg: parser PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants