Skip to content

fix(compiler): keep plain overload signatures non-ambient in the virtual TSX - #746

Merged
leonidaz merged 7 commits into
octanejs:mainfrom
zhsama:fix/esrap-overload-declare
Aug 13, 2026
Merged

leonidaz merged 7 commits into
octanejs:mainfrom
zhsama:fix/esrap-overload-declare

Conversation

@zhsama

@zhsama zhsama commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #736.

octane/compiler/volar emitted every bodyless function declaration as
declare function …, including plain TypeScript overload signatures. The
implementation signature stayed non-ambient, so TypeScript rejected the pair
with TS2384 ("Overload signatures must all be ambient or non-ambient") in the
editor and under tsrx-tsc, on source that compiles and runs fine.

The root cause was esrap's TSDeclareFunction printer writing declare
unconditionally instead of reading node.declare. esrap 2.3.2 guards the
modifier on the authored flag, so this PR raises the workspace esrap floor
from ^2.3.0 to ^2.3.2 (catalog, overrides, and the esrap_common anchor)
and adds a volar regression test.

The test compiles a .tsrx fixture containing an overload pair, an authored
ambient declare function, and a component using them, then runs the real
TypeScript checker over the virtual TSX and asserts zero diagnostics. The
oracle covers both directions: overloads wrongly made ambient report TS2384,
and an authored declare wrongly dropped reports TS2391.

A changeset on the patch track is included, since the published octane
package's dependency floor changes and the fix is consumer-visible.

After merging current main, pnpm sync refreshed the generated React-parity lockfile hashes and eval-corpus manifest for the new lockfile; those deterministic outputs are included.

Not addressed here: the adjacent TSDeclareMethod crash noted in #736 (throws
out of the mapping walker before any TSX is produced) lives in @tsrx/core
and still reproduces on 0.1.56; it needs an upstream fix.

CI follow-up: the required React-parity shard exposed a pre-existing timing race in the generated Syntax Highlighter loading-state adaptation. The test now holds loadLanguage() on a controlled pending promise, waits until loading has actually started, and then snapshots the plain-text fallback, so parity-wide runner load cannot race the oracle. The generated parity evidence hashes are refreshed.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm sync (rerun produced no remaining diff)
  • focused Volar regression: vitest run packages/octane/tests/compiler/volar.test.ts --reporter=verbose (15/15)
  • pnpm test: all prechecks passed and 20,944/20,945 tests passed; one unrelated browser-only Doom loading-state poll was transient
  • isolated Doom rerun: vitest run --project doom-browser playground/octane/tests/doom/doom-production.test.ts --reporter=verbose --silent=false (7/7)
  • exact required parity worker: pnpm react-parity:check --shard 2/3 (stable: 5,345 cases; canary: 5,413 cases)
  • generated Syntax Highlighter adaptation and parity-audit verification
  • focused Syntax Highlighter async suite on Node 24.18 and Node 24.19 (5/5)

The original-head compiler validation also passed vitest run --project octane (6,791 tests), vitest run --project octane-prod (5,641 tests), and vitest run packages/octane/tests/compiler/ (1,150 tests).

Provenance

  • An agent produced this diff (agent-authored)

Note

Low Risk
Scoped dependency bump on the TSX printer with a focused compiler test; remaining diff is generated hashes and a test-only flake fix, not runtime product logic.

Overview
Raises the workspace esrap floor from ^2.3.0 to ^2.3.2 so bodyless overload signatures in the Volar virtual TSX stay non-ambient while authored declare function still prints declare, fixing false TS2384 in the editor and tsrx-tsc (#736).

Adds a Volar regression test that typechecks compiled output with overloads plus an ambient declaration and expects zero diagnostics. Includes an octane patch changeset and refreshed lockfile hashes across react-parity audits and the eval train manifest after pnpm sync.

Separately stabilizes the generated Syntax Highlighter async loading-state parity test by mocking loadLanguage as pending and waiting for the load to start before snapshotting, with updated parity audit hashes for that package.

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

…ual TSX

esrap <2.3.2 printed `declare` on every bodyless function declaration, so a
plain overload pair next to its implementation typechecked as TS2384 in the
editor and under tsrx-tsc, on source that compiles and runs fine. Raise the
esrap floor to ^2.3.2, which guards the modifier on the authored flag, and pin
the contract with a volar regression test that runs the real TypeScript
checker over the virtual TSX.

Fixes octanejs#736

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Aug 12, 2026
@trueadm
trueadm marked this pull request as ready for review August 12, 2026 22:23
@leonidaz

Copy link
Copy Markdown
Collaborator

i'm looking into the flaky tests in #752

@trueadm

trueadm commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

i'm looking into the flaky tests in #752

I'll leave this PR to you then

@leonidaz
leonidaz merged commit c2e77a3 into octanejs:main Aug 13, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Virtual TSX emits declare on function overload signatures, producing TS2384

3 participants