Skip to content

feat: remove lazy destructuring (RFC #106) - #110

Merged
leonidaz merged 9 commits into
mainfrom
feat/remove-lazy-destructuring-106
Sep 14, 2026
Merged

leonidaz merged 9 commits into
mainfrom
feat/remove-lazy-destructuring-106

Conversation

@leonidaz

@leonidaz leonidaz commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Implements RFC #106: Remove lazy destructuring for everything owned by this repository. The @tsrx/ripple compiler and the Ripple runtime types live in the Ripple repository and will be migrated separately once this lands.

What changes

&{ ... } and &[ ... ] are no longer part of the TSRX language. & followed by { or [ in a binding, assignment, loop-header, or statement position is a plain syntax error, exactly as in TypeScript. There is no replacement syntax: every destructure is an ordinary destructure, combining props is an ordinary spread, and reactive state is read through the target's own API.

Before After
React / Preact: (&{ name }: Props) ({ name }: Props)
Solid: (&{ name }: Props) => <p>{name}</p> (props: Props) => <p>{props.name}</p> (or splitProps)
Vue: let &{ count } = state state.count, or const { count } = toRefs(state) and count.value
Ripple: let &[count] = track(0); count++ const count = track(0); count.value++

@tsrx/core

  • Parser plugin: removed the &{/&[ binding-atom override, the let & declaration detection, the expression-position pending-error tracking, the toAssignable / checkExpressionErrors overrides, and the statement-level &[x] = expr; form.
  • Transform: deleted transform/lazy.js (the __lazyN member-access rewrite), the pre-walk id allocation, and the post-lowering rewrite pass. The JSX transform now prints the lowered program directly.
  • Source maps: removed the __lazyN hover rewrites and lazy_param_binding_mappings; AssignmentPattern mappings no longer special-case lazy targets.
  • Analysis and diagnostics: removed UNSUPPORTED_LAZY_ASSIGNMENT_POSITION, its validator, and the assignment-position analysis.
  • Types: removed the lazy flag on ObjectPattern / ArrayPattern, the lazy / lazy_fallback binding kinds, lazy_array_* binding metadata, lazy_id / has_lazy_descendants / has_lazy_var_loop_descendants node metadata, LazyPattern / LazyContext / LazyBinding, and DestructuringErrors.lazyBindingPos.
  • Public API: removed createLazyContext, collectLazyBindings, collectLazyBindingsFromStatements, preallocateLazyIds, applyLazyTransforms, validateUnsupportedLazyAssignmentPosition, and TSRX_UNSUPPORTED_LAZY_ASSIGNMENT_POSITION_ERROR.

Targets

React, Preact, Solid, and Vue had no lazy-specific compiler code beyond the shared pass. Their test suites drop the lazy lowering cases, keep the runtime tests as plain-destructuring coverage, and each gains a test asserting the removed syntax is rejected.

Runtime

No runtime helper existed for lazy destructuring itself. While auditing the runtime for helpers that only existed to combine or forward props, the unused exclude_prop_from_object language helper (and its @tsrx/core/runtime/language-helpers re-export) is removed: its last in-repo callers were the Solid and Vue <Dynamic> runtime wrappers, replaced by compiler lowering in #1241, and with plain-object props a const { is, ...rest } = props spread covers the same need. Ref merging (normalize_spread_props and friends) is unchanged since it is keyed on ref symbols.

The core extractPaths utility and its DestructuredAssignment type are removed for the same reason: no in-repo consumer, and the lowering it emitted (_$_.exclude_from_object, _$_.array_slice) hard-coded Ripple runtime names inside the target-neutral core. The Ripple compiler is its only consumer and takes ownership of it.

Tooling and editors

  • Prettier plugin no longer prints & before patterns.
  • tsrx/no-lazy-destructuring-in-modules is removed from @tsrx/eslint-plugin and its recommended / strict configs.
  • Tree-sitter grammar drops lazy_object_pattern / lazy_array_pattern (parser regenerated); the Tree-sitter, Zed, and Neovim highlight queries drop the & captures.
  • TextMate grammar drops the &-prefixed destructuring rules; the tmbundle is regenerated.
  • MCP docs index and server prompt no longer mention the feature.

Docs

README, packages/tsrx/README.md, llms.txt, the specification page (section 4.5 removed, 4.6–4.7 renumbered to 4.5–4.6), the features and index pages, and the ESLint parser README are updated. The Ripple-powered compiler demo on the website is migrated to track() with .value. A blog post, "Removing lazy destructuring" at /blog/removing-lazy-destructuring, announces the change.

Validation

  • pnpm test: 95 files, 3860 passed, 33 skipped (pre-existing conditional skips)
  • pnpm typecheck: clean
  • pnpm changeset:check: clean
  • pnpm format:check: clean apart from gitignored IntelliJ sandbox artifacts
  • tree-sitter test: 69/69

Follow-ups (not in this PR)

🤖 Generated with Claude Code

leonidaz and others added 5 commits September 14, 2026 15:31
Remove the `&{ ... }` / `&[ ... ]` lazy binding patterns per RFC #106
(#106). The parser plugin no
longer recognizes the sigils in binding, assignment, loop-header, or
statement positions, so they fall through to Acorn's ordinary syntax
errors. Delete `transform/lazy.js`, the pre-walk id allocation and the
post-lowering rewrite in the JSX transform, the `lazy` pattern flag, the
`lazy` / `lazy_fallback` binding kinds, the lazy AST metadata, the
`__lazyN` hover rewrites and param binding mappings in the source-map
segments, the `UNSUPPORTED_LAZY_ASSIGNMENT_POSITION` diagnostic, and the
public lazy exports. Replace the lazy test suites with negative parse
tests and plain-destructuring mapping coverage.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…lid, and Vue

Follow-up to the core removal in RFC #106
(#106). Delete the lazy
lowering tests, rewrite incidental uses to plain destructuring, keep the
runtime rendering tests as plain-destructuring coverage, and add one
compile test per target asserting the removed syntax is rejected.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Per RFC #106 (#106): stop
printing `&` before patterns in the Prettier plugin, delete the
`tsrx/no-lazy-destructuring-in-modules` ESLint rule and its config
entries, drop the lazy example from the ESLint parser README, and remove
the lazy destructuring entry from the MCP docs index and server prompt.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Per RFC #106 (#106): drop the
`lazy_object_pattern` / `lazy_array_pattern` rules and regenerate the
Tree-sitter parser, remove the `&` operator captures from the Tree-sitter,
Zed, and Neovim highlight queries, and delete the `&`-prefixed
destructuring rules from the TextMate grammar and its generated tmbundle.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Per RFC #106 (#106): drop the
feature from the README feature list, the `llms.txt` guide and quick
reference, the specification (section 4.5 and its grammar productions,
with later sections renumbered), the features and index pages, and
migrate the Ripple compiler demo to `track()` with `.value` reads.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@vercel

vercel Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
tsrx-website Ready Ready Preview Sep 14, 2026 9:07pm UTC
tsrx-website-mcp Ready Ready Preview Sep 14, 2026 9:07pm UTC

Request Review

@cursor

cursor Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

This PR is too large for Bugbot to review. It changes 100,448 lines and 4,074,340 characters. Split the change into smaller pull requests to get a review.

@leonidaz

Copy link
Copy Markdown
Contributor Author

reviewing it with Astra since bugbot refused.

The `checkLValPattern` override was introduced alongside lazy patterns but
fixes a general acorn-typescript gap: `[{ a } as T] = arr` otherwise fails
with "Assigning to rvalue". Its only coverage used `&{ ... }` and was
removed with the feature, so add a plain-TypeScript regression test.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Its last in-repo callers were the Solid and Vue `<Dynamic>` runtime
wrappers, which were replaced by compiler lowering in #1241. Props are
plain objects, so the getter-forwarding object has no remaining purpose;
a `const { is, ...rest } = props` spread covers the same need.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Nothing in this repository consumed them, and the lowering they produced
emitted Ripple runtime names (`_$_.exclude_from_object`,
`_$_.array_slice`) from the target-neutral core. The Ripple compiler is
the only consumer and takes ownership of that helper.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@leonidaz

Copy link
Copy Markdown
Contributor Author

Ok, reviewed with Astra, all good now.

@leonidaz
leonidaz requested a review from trueadm September 14, 2026 20:45

@trueadm trueadm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to create a TSRX blog post for this and update SWC and the OXC ports too.

Announce the RFC #106 removal
(#106): why the feature
existed, what was wrong with it, what to write instead per target, and
the mechanical migration.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@leonidaz

Copy link
Copy Markdown
Contributor Author

We'll need to create a TSRX blog post for this and update SWC and the OXC ports too.

I created issues for OXC and Yuku (tsrx-org/oxc and tsrx-org/yuku) but SWC I think only does the TSX printing of the final ast, so lazy destructure doesn't appear there.

@leonidaz
leonidaz merged commit dcc0283 into main Sep 14, 2026
11 checks passed
leonidaz added a commit that referenced this pull request Sep 14, 2026
…d grammar rev (#111)

* chore(release): allow minor bumps, upgrade changesets to 3.x, sync Zed grammar rev

Switch the RFC #106 changesets from PR #110 to `minor` and upgrade
`@changesets/cli` to ^3.0.2 so that peer-dependent packages are bumped by
`patch` instead of `major`. Under 2.x the `@tsrx/typescript-plugin` peer
dependencies on the target compilers would have pushed its fixed group
(eslint-parser, eslint-plugin, language-server, prettier-plugin) to 1.0.0.

- `scripts/check-changesets.js` now rejects only `major`; CI step names and
  the RuleSync bump policy are updated to match.
- Point `.changeset/config.json` `$schema` at config 4.0.0.
- Sync the Zed grammar rev to dcc0283 so the extension builds the
  tree-sitter grammar without lazy destructuring.
- Fix `sync-zed-grammar-rev.js` exiting the parent version script early on
  the already-synced path, which skipped the Zed Cargo.toml version update.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* ci: migrate to changesets/action@v2 for the Changesets 3 CLI

Changesets CLI 3 no longer prints the `New tag:` lines that
changesets/action@v1 parsed to find published packages, so v1 would publish
to npm but never create git tags or GitHub releases. v2 reads the CLI's
`CHANGESETS_OUTPUT` file instead and validates that the project uses CLI 3.

- Rename inputs (`version` -> `version-script`, `publish` -> `publish-script`,
  `commit` -> `commit-message`, `title` -> `pr-title`) and pass the token
  through the `github-token` input, which v2 requires.
- Keep `GITHUB_TOKEN` in the release workflow only, where
  `@changesets/changelog-github` reads it.
- v2 dropped writing `.npmrc` from `NPM_TOKEN`, so the bootstrap workflow now
  authenticates through `actions/setup-node` `registry-url` and
  `NODE_AUTH_TOKEN`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
leonidaz added a commit that referenced this pull request Sep 14, 2026
…113)

These helpers only backed lazy destructuring and the `extractPaths`
lowering, both removed in #110. Their last consumer, the Ripple compiler,
now lowers rest and default patterns with native destructuring
(Ripple-TS/ripple#1472), so nothing emits or imports them any more.

Co-authored-by: Claude Fable 5.1 <[email protected]>
thejackshelton added a commit to tsrx-org/yuku that referenced this pull request Sep 15, 2026
tsrx removed lazy destructuring (`&{ ... }` / `&[ ... ]`) from the language
in tsrx-org/tsrx#110. `&` directly before `{` or `[` in a binding,
assignment, loop-header, or statement position is now a plain syntax error
from the ordinary parser, as in TypeScript. `a & { b: 1 }` and `x & [1]`
are still bitwise AND. Ordinary destructuring is the only destructuring.

- delete src/dialect/patterns.zig and the lazy_assignment_pattern,
  binding_pattern, and can_start_binding parser hooks; the seam falls
  through to its ordinary parser on its own
- drop the ArrayPattern/ObjectPattern overlay records from the schema and
  ABI and regenerate the decoders (record tags renumber to 183/184/185)
- stop printing the `&` prefix in codegen
- delete the lazy fixtures, snapshots, benchmark pairs, and tests; add the
  six reference negative cases and bitwise-AND positives to m4.zig and
  m4.test.ts; de-lazy the control-flow-try fixture
- docs: README parse list, the dialect page, and Limitations

Closes #2
This was referenced Sep 25, 2026
leonidaz added a commit that referenced this pull request Sep 25, 2026
…declarations, and decorators on a rest parameter (#194, #533, #564) (#614)

* fix(core): parse anonymous and decorated default-exported classes as declarations, and decorators on a rest parameter (#194, #533, #564)

Four parser bugs caused upstream in @sveltejs/acorn-typescript 1.0.13, each
worked around by overriding the responsible method in TSRXPlugin, marked
`UPSTREAM(sveltejs/acorn-typescript#<n>)`, with the AST of the upstream fix:

- #194: `parseClassId` skips `implements` wherever the class name is
  optional, with `id: null`, and `parseExportDefaultDeclaration` parses
  `export default abstract class` with an optional name. Upstream:
  sveltejs/acorn-typescript#113 (also #110 for the abstract part).
- #533: `parseExportDefaultDeclaration` reads the decorators after
  `export default` and parses `class` or `abstract class` as a declaration,
  so `export default @dec class B {}` is a ClassDeclaration that binds `B`
  and `export default @dec abstract class {}` parses. Node ranges don't
  change. Upstream: sveltejs/acorn-typescript#124.
- #533 (last row): `parseDecorators` checks that decorators written before
  `export` are followed by an exported class, and reports them otherwise with
  the existing "Leading decorators must be attached to a class declaration."
  error, instead of dropping them or moving them onto a class expression.
  Upstream: sveltejs/acorn-typescript#125.
- #564: `parseAssignableListItem` reads the decorators before `...` and hangs
  them off the RestElement, as typescript-estree does. Like any parameter
  decorator this is not an error: TypeScript's checker decides (TS1206 unless
  experimentalDecorators). Upstream: sveltejs/acorn-typescript#126.

tsrx-prettier-plugin no longer retypes a decorated default-exported class
expression as a declaration, which the parser now produces.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(core): don't let an at-sign construct after `export` pass for a decorator (#533)

The check for decorators written before `export` deferred to the later
decorator check when `@` followed `export` or `export default`. An at-sign
construct there (`@if (a) { … }`, `@{ … }`) is an expression, not a
decorator, so nothing checked the leading decorators, and the next class took
them: `@dec export default @if (a) { … }` followed by `class A {}`
decorated `A`. Report them at the construct instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Sep 25, 2026

This branch was successfully deployed

2 active deployments
Preview – tsrx-website — 91c3b30a Deployed Sep 14, 2026 by vercel[bot]
Preview – tsrx-website-mcp — 91c3b30a Deployed Sep 14, 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.

2 participants