Skip to content

Fix Octane TSRX parser compatibility - #10

Merged
thejackshelton merged 1 commit into
tsrx-org:mainfrom
trueadm:codex/octane-integration-compat
Aug 12, 2026
Merged

thejackshelton merged 1 commit into
tsrx-org:mainfrom
trueadm:codex/octane-integration-compat

Conversation

@trueadm

@trueadm trueadm commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add parser support for multiline JSX attributes, TypeScript generic disambiguation, JSX shorthand attributes, raw script payloads, and lazy destructuring
  • correct scanner expression state around statement blocks, postfix non-null assertions, return types, and JSX boundaries
  • preserve reference-compatible namespace imports and parenthesized JSX sequence expressions while retaining other OXC diagnostics
  • reuse source-sorted reconstruction indexes so the new sparse compatibility paths remain linear

Root cause

The Octane corpus exposed several places where the parser scanner applied ordinary JavaScript or JSX assumptions to valid TSRX authoring forms. A smaller set parsed successfully in OXC but produced a different AST shape or an extra TypeScript diagnostic compared with the reference TSRX parser.

The scanner, projection overlay, marker validation, and reconstruction passes now carry those authored forms explicitly and restore their exact spans and metadata after the single OXC parse.

Impact

The Octane corpus improves from 39 failures to zero failures across 2,137 .tsrx files. The compatibility AST remains scaffold-free and the new reconstruction work uses the existing indexed object pass.

A warm in-memory Apple arm64 corpus comparison measured a 297.21 ms median for this branch versus 1,616.71 ms for @tsrx/[email protected], or 5.44x faster.

Validation

  • cargo test --release --locked --offline -p tsrx_syntax -p oxc_adapter -p tsrx_parser_engine
  • cargo clippy --release --locked --offline -p tsrx_syntax -p oxc_adapter -p tsrx_parser_engine --all-targets -- -D warnings
  • pnpm test:parser-api (9/9)
  • OXC_TSRX_PARSER_ADDON=packages/toolchain/parser.node pnpm test:parser-addon (1/1)
  • full Octane corpus replay (2,137/2,137 parsed)
  • git diff --check

Closes #9

@trueadm
trueadm marked this pull request as ready for review August 12, 2026 21:32
@thejackshelton
thejackshelton merged commit 14147ff into tsrx-org:main Aug 12, 2026
@thejackshelton

Copy link
Copy Markdown
Contributor

Reviewed and merged as-is (rebase, 14147ff) — thanks Dominic, the diff held up well under review: validation claims reproduced locally (cargo test 273/0, clippy clean, parser-api 9/9, addon 1/1), the reconstruct passes are fail-closed, and the diagnostic suppression is narrowly scoped with a carried count.

Two follow-ups landed/noted:

  1. 343ae86 on main (kept out of your branch deliberately): TDD fix for issue Two TSRX defects: parser applies no ASI before a JSX line, and Oxfmt refuses @if when semi flips #8 defect 1 — both scanner lanes now start a statement at a line-leading committed markup opening, with a projected ; so OXC reads the same boundary. Guard tests cover comparisons and TS type-parameter forms.
  2. Issue Two TSRX defects: parser applies no ASI before a JSX line, and Oxfmt refuses @if when semi flips #8 defect 2 (Oxfmt structural refusal on trailing @if) has a different root cause: code_context scans back from the @, sees ), and returns ControlContext::Expression for a line-leading control after a semicolon-less statement. Left open in Two TSRX defects: parser applies no ASI before a JSX line, and Oxfmt refuses @if when semi flips #8 — changing it shifts statement-vs-expression reconstruction and deserves its own PR.

One observation, no action needed: dropping else/do from can_start_expression means an unbraced else /re/.test(x) would lex the / as division. No fixture covers it; flagging in case it was unintentional.

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.

Octane integration report: 39 corpus parse failures and AST compatibility gaps

2 participants