Skip to content

fix(core): map TS parameter properties and bodyless class methods - #143

Merged
trueadm merged 2 commits into
mainfrom
fix/mapping-walker-class-ts-members
Sep 23, 2026
Merged

trueadm merged 2 commits into
mainfrom
fix/mapping-walker-class-ts-members

Conversation

@trueadm

@trueadm trueadm commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The source-mapping walker in segments.js now handles TSParameterProperty and TSDeclareMethod.
  • The typeOnly/volar printer keeps override on parameter properties.

Why

  • Any .tsrx file with a constructor parameter property (constructor(private readonly start: number) {}) or a bodyless class method (overload signature, abstract m(): T;, optional m?(): T;) made the walker throw Unhandled AST node type in mapping walker: …. tsrx-tsc then fell back to raw text and reported bogus TS1144/TS1005/TS1128 syntax errors instead of type-checking the file.
  • esrap's TSParameterProperty printer (still true in 2.3.9) writes accessibility and readonly but not override. So constructor(override readonly n: number) failed with TS4115 under noImplicitOverride.

Changes

  • segments.js: TSParameterProperty visits its parameter, plus the Identifier's annotation (an AssignmentPattern visits its own). TSDeclareMethod visits typeParameters, params with annotations, and returnType. MethodDefinition has already visited the key.
  • jsx/helpers.js: a TSParameterProperty printer override that writes accessibility override readonly.
  • tests/shared/source-mappings.js: 7 shared cases covering parameter properties, override, overloads, abstract members, optional methods, name/annotation mappings, and modifier preservation. They run under every target and fail without this change.

Validation

  • tsgo --noEmit -p packages/tsrx/tsconfig.json: clean.
  • vitest run packages/tsrx*/tests: 3469 passed.
  • Downstream, Octane applies this as a pnpm patch on @tsrx/core 0.2.0. tsrx-tsc now type-checks the original repro, and a planted error is reported on the correct line.

Follow-ups

  • esrap's Identifier printer also drops parameter decorators (@dec() x). That only matters with legacy experimentalDecorators, so it's left for later.

🤖 Generated with Claude Code


Note

Medium Risk
Touches the core Volar/source-map walker and TS print path used for every .tsrx file; scope is narrow but affects type-checking correctness for class-heavy code.

Overview
Fixes editor/type-checking failures for .tsrx files that use common TypeScript class syntax: constructor parameter properties and bodyless methods (overloads, abstract, optional signatures).

The source-mapping walker in segments.js now visits TSParameterProperty (parameter + type annotations) and TSDeclareMethod (generics, params, return type) instead of throwing and forcing tsrx-tsc to fall back to raw source with bogus parse errors.

The virtual TypeScript printer in jsx/helpers.js adds a TSParameterProperty override so override is emitted with accessibility/readonly (fixes TS4115 under noImplicitOverride).

Shared source-mapping tests cover parameter properties, override preservation, overloads, abstract/optional members, and name/annotation mappings.

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

The source-mapping walker threw "Unhandled AST node type in mapping walker"
on TSParameterProperty (`private readonly x: T`) and TSDeclareMethod
(overload signatures, abstract and optional methods), so tsrx-tsc fell back
to raw text and reported bogus syntax errors. Also print `override` on
parameter properties, which esrap drops.

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

vercel Bot commented Sep 23, 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 23, 2026 11:22am UTC
tsrx-website-mcp Ready Ready Preview Sep 23, 2026 11:22am UTC

Request Review

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 89d4759. Configure here.

Comment thread packages/tsrx/src/transform/segments.js Resolved
@trueadm
trueadm marked this pull request as ready for review September 23, 2026 08:51
domgan-oai pushed a commit to octanejs/octane that referenced this pull request Sep 23, 2026
…ss methods (#1276)

tsrx-tsc threw "Unhandled AST node type in mapping walker" on constructor
parameter properties (TSParameterProperty) and bodyless class methods
(TSDeclareMethod: overloads, abstract, optional), fell back to raw text,
and reported bogus TS1144/TS1005/TS1128. The printer also dropped
`override` on parameter properties. Carry the upstream fix
(tsrx-org/tsrx#143) as a pnpm patch until a release ships it.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm enabled auto-merge (squash) September 23, 2026 14:58
@trueadm
trueadm disabled auto-merge September 23, 2026 14:58
@trueadm
trueadm merged commit f1a21f6 into main Sep 23, 2026
11 checks passed
@trueadm
trueadm deleted the fix/mapping-walker-class-ts-members branch September 23, 2026 14:58
@cursor cursor Bot mentioned this pull request Sep 23, 2026
trueadm pushed a commit to octanejs/octane that referenced this pull request Sep 24, 2026
* fix: update the TSRX toolchain to @tsrx/core 0.3.2

Update the shared TSRX packages to the release in tsrx-org/tsrx#218 and
drop the @tsrx/[email protected] patch, which core 0.3.0 ships
(tsrx-org/tsrx#143). Core now gives each @switch arm its own block scope,
so arms may declare the same local and an arm's `apply` resolves to its
own style block.

Core lowers a @for whose body awaits to `__map_iterable_async` in the
editor's virtual TSX:

- Re-export `map_iterable_async` from `octane/tsrx-iterable` and require
  it in verify-dist, so the helper import resolves and the loop binding
  keeps its type (#1291).
- Claim `__map_iterable_async` as a @for origin, so type inspection
  resolves the keyword instead of the whole loop (#1292).

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

* fix(drei): cast state.controls through unknown, as upstream does

tsrx-tsc from @tsrx/typescript-plugin 0.4.10 now maps the TS2352 that
TypeScript reports for a direct cast from `EventDispatcher<{}> | null`
to `ControlsProto | undefined` or `{ enabled: boolean } | undefined`, so
the drei adapted-types parity lane failed. Upstream drei casts through
`unknown` at each of these sites; the port had dropped that step.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was successfully deployed

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

1 participant