Skip to content

feat(syntax): remove lazy destructuring for tsrx RFC #106 parity - #86

Merged
thejackshelton merged 1 commit into
mainfrom
fix/issue-85-remove-lazy-destructuring
Sep 15, 2026
Merged

thejackshelton merged 1 commit into
mainfrom
fix/issue-85-remove-lazy-destructuring

Conversation

@thejackshelton

@thejackshelton thejackshelton commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Removes lazy destructuring (&{ … } / &[ … ]) to match tsrx RFC #106 (tsrx-org/tsrx#110). & directly before { or [ in binding, assignment, loop-header, arrow-parameter, catch-parameter, statement, @for, and @catch position is now a plain TypeScript syntax error, exactly as in TypeScript; bitwise & is unchanged.

Closes #85. Closes #40: the remaining parity gap it describes (lazy patterns nested in assignment targets and TS wrappers) no longer exists on either side.

What changed

  • crates/tsrx_syntax: ParserLazyPattern and Overlay.parser_lazy_patterns are gone, along with every scanner path that registered them (parser_scanner/{lexical,header,control,region,state,overlay}.rs), both projection lanes' lazy actions and Y markers, and the formatter lift that re-printed the &. Helpers whose only callers were the lazy paths (skip_balanced_pattern, arrow_follows_parameter_list, skip_type_expression, previous_significant_end, and friends) are deleted rather than allowed.
  • crates/tsrx_parser_engine: reconstruct/lazy_patterns.rs is deleted with its wiring in program.rs, pipeline.rs, projection/gaps.rs, and projection/marker_validation.rs.
  • Tests: the lazy tests in program_composition.rs, public_api.rs, tsrx_format, and one tsrx_lint fixture are replaced by lazy_destructuring_is_not_supported (the six tsrx negative cases plus catch (&{ m }) and three @for/@catch forms, all asserted as Grammar-phase failures) and a positive regression for wrapped nested patterns and bitwise &.
  • docs/tsrx.tmLanguage.json: the six & highlighting rules the site grammar carried for lazy patterns are edited back to the upstream TypeScript-TmLanguage shape.

Notes against the issue text

  1. The issue names a porting spec tracking tsrx's parser tests. No such document exists in this repository; the negative tests above are the tracking artefact.
  2. crates/tsrx_format needed only a test change. The & re-printer lived in crates/tsrx_syntax/src/projection/lift/parser.rs.
  3. crates/tsrx_syntax/src/parser_scanner/control.rs (the @for / @catch hooks) was missing from the issue's list and is included.
  4. None of docs/README.md, docs/archive/tsrx-parser-api.md, packages/vscode/README.md, or website-oxc mention lazy destructuring; their lazy hits are the lazy result transport or lazy-loaded assets. The only doc artefact touched is the TextMate grammar.
  5. [{ a } as T] = arr is rejected by both OXC ("Cannot assign to this expression") and tsc 6 (TS2364), so it is asserted as a rejection. The wrapped-nested-pattern regressions that parse clean are [{ a }] = arr, [a as T] = arr, and [(a)] = arr.
  6. The lazy result transport (capabilities.lazy, experimentalLazy, utf16-lazy, the lazy_result lanes in parser_napi_binding) is untouched.

Observed behaviour

With the scanner no longer registering the sigil, the & is copied verbatim into the projection and OXC reports Unexpected token at it (Grammar phase); let &{ a } = b; reads as bitwise let & {a} and fails with Cannot assign to this expression. .tsrx files with no other TSRX constructs take the direct OXC path and get OXC's unmodified diagnostic.


Note

Medium Risk
Large removal across scan, project, reconstruct, and format paths changes how binding syntax parses and fails; misclassification of bitwise & vs errors could affect existing .tsrx that used lazy destructuring.

Overview
Removes lazy destructuring (&{…} / &[…]) across the stack so TSRX matches RFC #106: an & immediately before { or [ in binding positions is treated as invalid TypeScript, not a special TSRX form. Bitwise & and normal destructuring are unchanged.

The overlay no longer carries ParserLazyPattern metadata. Scanner registration, parser/type/format projection (including Y markers and format lift), gap/marker validation, and AST reconstruction in lazy_patterns.rs are deleted. Parser pipeline direct-parse eligibility no longer depends on lazy-pattern overlays.

Tests and fixtures switch from asserting lazy round-trips to rejecting lazy spellings (including @for / @catch) and accepting plain nested patterns and & in type/intersection/bitwise contexts. The TextMate grammar drops the extra &-before-pattern highlighting rules.

Reviewed by Cursor Bugbot for commit 546bda7. Bugbot is set up for automated code reviews on this repo. Configure here.

`&` directly before `{` or `[` in binding, assignment, loop-header,
arrow-parameter, catch-parameter, statement, @for, and @catch position is a
plain TypeScript syntax error again, as it is in tsrx since tsrx-org/tsrx#110.
There is no replacement syntax; bitwise `&` is unchanged.

Removes ParserLazyPattern, Overlay.parser_lazy_patterns, every scanner path
that registered them, both projection lanes' lazy actions and markers, the
formatter lift that re-printed the sigil, reconstruct/lazy_patterns.rs and
its wiring, and the helpers whose only callers were those paths. The lazy
tests become lazy_destructuring_is_not_supported plus a positive regression
for wrapped nested patterns and bitwise `&`. The site TextMate grammar drops
its six lazy-pattern highlighting rules.

Closes #85. Closes #40.
@vercel

vercel Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tsrx-website-oxc Ready Ready Preview Sep 15, 2026 1:50am UTC

Request Review

@thejackshelton
thejackshelton merged commit 2f41244 into main Sep 15, 2026
15 checks passed
@thejackshelton
thejackshelton deleted the fix/issue-85-remove-lazy-destructuring branch September 15, 2026 02:07

This branch was successfully deployed

1 active deployment
Preview — 546bda78 Deployed Sep 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove lazy destructuring (tsrx RFC #106 parity) Lazy patterns nested in assignment targets and TS wrappers (tsrx decbe8f parity)

1 participant