Skip to content

fix: keep comments after a signature's closing parenthesis or arrow in place - #185

Merged
dummdidumm merged 3 commits into
sveltejs:mainfrom
leonidaz:fix/signature-trailing-comments
Sep 3, 2026
Merged

dummdidumm merged 3 commits into
sveltejs:mainfrom
leonidaz:fix/signature-trailing-comments

Conversation

@leonidaz

@leonidaz leonidaz commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Split out of #183 at the maintainers' request.

Call signatures, method signatures and function types bounded their parameter list's trailing comments at the return type's inner type, or not at all when there was no return type. Comments written after the closing parenthesis or after => were therefore pulled inside the parameter list:

// input
type F = (a: A /* c1 */) /* c2 */ => /* c3 */ T;
type G = { (a /* c1 */) /* c2 */ };

// before
type F = (a: A /* c1 */ /* c2 */ /* c3 */) => T;
type G = { (a /* c1 */ /* c2 */) };

// after
type F = (a: A /* c1 */ /* c2 */) => /* c3 */ T;
type G = { (a /* c1 */) /* c2 */ };

The bound is now the return type annotation, falling back to the node's end, which is what function declarations already use. A fixture covers the placements.

🤖 Generated with Claude Code

The parameter lists of call signatures, method signatures and function
types flushed trailing comments up to the return type's inner type (or,
without a return type, without bound), so comments written after the
closing parenthesis or after `=>` were pulled into the parameter list.
Bound them at the return type annotation, falling back to the node's
end, as function declarations already do.
@pkg-svelte-dev

pkg-svelte-dev Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Install the latest version of esrap from 0479cad:

pnpm add https://pkg.svelte.dev/esrap/c/0479cad1350f4f30fb9eb04ec59a131b4e7f5702

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/esrap/pr/185

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0479cad

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
esrap Patch

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

@dummdidumm
dummdidumm merged commit 2e4485b into sveltejs:main Sep 3, 2026
6 checks passed
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.

2 participants