Skip to content

Remove lazy destructuring (tsrx RFC #106 parity) #85

Closed

Description

@leonidaz

tsrx has removed lazy destructuring (&{ ... } / &[ ... ]) from the language: RFC #106, implemented in tsrx-org/tsrx#110. @tsrx/oxc should follow so the two parsers agree on what TSRX is.

New reference behavior

& directly 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; ordinary destructuring is the only destructuring. a & { b: 1 } and x & [1] are still bitwise AND.

tsrx's parser now carries these negative tests (packages/tsrx/tests/utils/parser.test.js, "lazy destructuring is not supported"):

function f(&{ a }) {}        // Unexpected token
const &[x] = y;              // Unexpected token
let &{ a } = b;              // The keyword 'let' is reserved
for (const &{ v } of items) {}
&[x] = expr;                 // statement-level form
(&{ a }) => a;

What to remove here

From a code search of this repository for lazy_pattern / lazy:

  • crates/tsrx_parser_engine/src/reconstruct/lazy_patterns.rs and its wiring in reconstruct/mod.rs, reconstruct/program.rs, pipeline.rs, projection/gaps.rs, projection/marker_validation.rs
  • crates/tsrx_syntax: model.rs, scanner/mod.rs, parser_scanner/{lexical,header,overlay,region,state}.rs, parser_projection/{actions,builder,validate}.rs, projection/{builder,format}.rs, projection/lift/parser.rs
  • crates/tsrx_format/src/lib.rs (printing the & prefix)
  • tests: crates/tsrx_parser_engine/tests/program_composition.rs and any lazy corpus cases
  • docs: docs/README.md, docs/archive/tsrx-parser-api.md, packages/vscode/README.md, website-oxc, and the porting spec that tracks tsrx's parser tests (the lazy cases in tsrx are gone; the replacements are the negative tests above plus a plain-TypeScript regression for wrapped nested patterns, [{ a } as T] = arr)
  • packages/toolchain/src/{parser,runtime}.ts if they expose lazy node kinds

This also closes #40: the remaining parity gap it describes (lazy patterns nested in assignment targets and TS wrappers) no longer exists on the tsrx side.

Ordering

tsrx's @tsrx/core release with the removal is the reference; keep this in sync with whichever core version @tsrx/oxc pins. Ripple's own compiler follows separately in Ripple-TS/ripple#1471.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions