Repository navigation
fix: disambiguate generic arrows in the TSX printer - #188
Merged
Rich-Harris merged 2 commits intoSep 21, 2026
Merged
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/esrap/c/e246144bd35338cbfceb755ab80ba91f7dae6250Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: e246144 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This was referenced Sep 25, 2026
6 of 7 tasks
trueadm
added a commit
to octanejs/octane
that referenced
this pull request
Oct 29, 2026
…e .tsrx type view (#2284) 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]>
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.
Generic arrows such as
const identity = <T,>(value: T): T => valuelose their trailing comma when printed withtsx(), producing invalid TSX. OverrideTSTypeParameterDeclarationin the TSX printer so single-parameter declarations always include the comma by default.A trailing comma is valid TypeScript syntax in a type-parameter declaration and does not change its meaning. It is therefore safe to emit consistently, including for constrained/defaulted parameters and single-parameter function, class, interface, and type declarations where it is not required to resolve JSX ambiguity. Multiple-parameter lists and type arguments retain their existing formatting. Both public function signatures and the shared TS printer are unchanged.
Supersedes #155 and addresses the reviewer's API concern using the existing visitor overrides, without adding a parameter or moving the TS implementation.
The sample runner now uses
tsx()forjsx-*/tsx-*fixture directories andts()for the rest. AST comparisons ignore Acorn's trailing-comma source offsets. Regression coverage includes code and sourcemap snapshots, nested and async arrows,constparameters, constraints/defaults, and TS input with no original comma.Update the
@sveltejs/acorn-typescriptdevelopment dependency from 1.0.5 to 1.0.13, which includes the upstream fixes for generic async arrows. The dedicated TSX regression tests use Acorn, including the async cases.Validation:
pnpm test— 316 tests passedpnpm check— passedpnpm lint— passed