Repository navigation
fix(compiler): typecheck generic arrows and directive arm exits in the .tsrx type view - #2284
Merged
Merged
Conversation
…e .tsrx type view The virtual TSX that the editor and octane-tsc check rejected two shapes the compiler accepts: - `const first = <T,>(xs: T[]) => xs[0]` printed as `<T>(…)`, which TSX reads as a JSX element `T` (TS17008 plus a syntax-error cascade). esrap 2.3.2's TSX printer drops the trailing comma; backport sveltejs/esrap#188 (2.3.8) as a patch, since bundle-volar.mjs freezes this esrap into the published `octane/compiler/volar`. - `return;`, `return null;` and an unowned `continue;` that end a directive arm early reported TSRX2005/TSRX2002/TSRX2007. The shared transform checks arms against TSRX's own rules, which have no exits. The type view now prints an exit `continue;` as `return;` from the function the arm becomes, so the rest of the arm is narrowed, and drops the shared reports at those exits. Value returns and directive breaks are still reported, as compiling rejects them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 29, 2026 10:45
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | b2e3edd | Commit Preview URL Branch Preview URL |
Oct 29 2026, 10:46 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | b2e3edd | Commit Preview URL Branch Preview URL |
Oct 29 2026, 10:47 AM |
Contributor
Benchmark report🟢 No byte growth, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 111 measured values. Public-import reachability bundles (bytes)No changes across 141 measured values. |
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
.tsrxTypeScript view that the editor andoctane-tsccheck (compileToVolarMappings) rejected two shapes thatcompile()accepts. The@octanejs/codemodmigration of Memos and T3 Code (#2280) emits both, and 3 Memos modules failed typecheck.const first = <T,>(xs: readonly T[]) => xs[0]printed as<T>(…). TSX reads that as a JSX elementT, so it reported TS17008 plus a cascade of syntax errors.return;,return null;, and an unownedcontinue;end an arm early (arm-exits.js,tsrx-authoring.md). In an@forbody they reported TSRX2005/TSRX2007, and in an@ifarm TSRX2002. Acontinue;inside themap_iterablecallback was also invalid JavaScript.Why: owners
<T>for every type-parameter list. fix: disambiguate generic arrows in the TSX printer sveltejs/esrap#188 (4a0bb7f, released in 2.3.8) fixed it upstream. This repo is held at 2.3.2, andpackages/octane/scripts/bundle-volar.mjsdeliberately freezes that esrap into the publishedoctane/compiler/volar, so every consumer has the bug. Upgrading instead would also take esrap 2.3.11, which removed theboundaryTokensoption that@tsrx/core0.5.5 maps structural tokens with. So this PR backports the upstream commit aspatches/[email protected], byte-for-byte. Because the bundle carries the patch, it ships.@tsrx/core's shared transform checks arms against TSRX's own rules, and that is correct for those targets. Octane's view adapts it the same way its othervolar.jsprojections do. No@tsrx/coreAPI or patch is needed.Changes
patches/[email protected]+pnpm-workspace.yamlpatchedDependenciesentry, with the scope and the condition for dropping it. The lockfile only gains the patch hash. A stray@types/react-domcatalog re-resolution was reverted, andpnpm install --frozen-lockfilepasses.compiler/arm-exits.js:mapArmExits(ast, exit)is a copy-on-write, module-wide walk that classifies exits with the existingarmJump. It follows the same boundariescompile.jsuses: nested functions and@{ … }blocks own their jumps, inner loops own theircontinue, and a nested directive starts its own arm.compiler/volar.js:projectArmExitsprints an exitcontinue;asreturn;, a return from the function the arm becomes. Every exit then narrows the rest of the arm in TypeScript. The projection also records the exits' starts, andcompileToVolarMappingsdrops only the shared transform'sFOR_RETURN_STATEMENT/IF_RETURN_STATEMENTreports at those positions.compileTypesInspectiongets the same projection, so both entries still print the same transform.return 1;) and abreakthat leaves the directive are still reported, ascompile()rejects both.Validation
vitest run packages/octane/tests/compiler/volar.test.ts --project octane: 46/46 pass. Two new cases, both seen failing before the fix:Tis inferred.@forreturn null;+continue;, an inner loop's owncontinue, a@switchcasecontinue;, and an@ifreturn;. It checks both the mappings and inspection output, with the narrowing required understrict. An invalid row must report exactly TS2339 (the row is notany), andreturn 1;still reports TSRX2005.continue→returnrewrite fails the test, and so does dropping the report filter.octane-tscend to end (node scripts/typecheck-files.mjs -- <repro>.tsrx). Before the fix: TS17008, TSRX2005, TSRX2007 and syntax errors. After: clean. Negative control:item.user.labelreports TS2339 on{ name: string; }, i.e. narrowed. The scratch file was removed.pnpm format:files:checkandpnpm typecheck:fileson the changed filespnpm format:check,pnpm typecheck,pnpm test: left to CI (local test-load rule)perf-review:node scripts/perf-review-scan.mjsand… packages/octane/src/compiler/: 0 candidates. No runtime source changed.compile()output is unchanged: it neither importsmapArmExitsnor prints types. The new walk runs once per type-view compile (editor/octane-tsc), O(AST), like the existingprojectNativeDomReads/projectComponentChildrenwalks. Not measured: no runtime or app-output path changes.concise-code: src +74 −3 (runtime +0 −0, compiler only). New files:patches/[email protected](backport) and a changeset. New export:mapArmExits(caller:volar.js).@tsrx/corepatch adding avalidation.armExitsplatform option (~40 patch lines across two validators and the for/if lowering, carried on every@tsrx/corebump for an Octane-only contract).compile.js'sreplaceArmExits(per-arm and throwing, andvolar.jsstays out ofcompile.js).boundaryTokensremoval).Risk / follow-ups
function f<T,>(),class C<T,>), matching esrap ≥2.3.8. That is valid TS. Mappings are unaffected, and the bundle-equality test passes.return null;in a@trybody is a parse error from@tsrx/oxc("return is outside an authored return boundary"), althougharm-exits.jslists@try/@pending/@catchexits. Separate defect.@tsrx/[email protected]patch's SCOPE comment says it does not ship, butbundle-volar.mjsalso freezes the patched@tsrx/coreintooctane/compiler/volar.@tsrx/reactand the other Volar targets likely have the same<T>printing. Not filed.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Changes only the type-checking AST/print path (not
compile()output), but incorrect exit or generic printing could hide real errors or confuse narrowing across@for/@ifarms.Overview
Aligns the virtual TSX used by the editor and
octane-tscwith code that already **compile()**s, fixing two false-positive classes of diagnostics.One-parameter generic arrows in
.tsrxno longer print as<T>(…), which TSX parses as JSX and triggered TS17008 and follow-on syntax errors. An[email protected]patch (upstream fix from esrap 2.3.8) prints<T,>for single type-parameter lists; it is wired throughpnpm-workspace.yamland ships in the bundled Volar compiler.Directive arm early exits (
return;,return null;, andcontinue;not owned by an inner loop) are modeled the way lowered arms behave: newmapArmExitsinarm-exits.jsfinds those jumps,projectArmExitsinvolar.jsrewrites unownedcontinuetoreturn;for checking and suppresses TSRX2002/2005/2007 at those sites so the rest of the arm type-checks with narrowing (e.g. afterif (!row.user) continue;). Value returns andbreakout of a directive are still reported.Coverage is added in
volar.test.ts; lockfilereact-parity.jsonhashes update from the dependency patch.Reviewed by Cursor Bugbot for commit b2e3edd. Bugbot is set up for automated code reviews on this repo. Configure here.