Skip to content

fix: print a semicolon after body-less class methods - #186

Merged
dummdidumm merged 4 commits into
sveltejs:mainfrom
leonidaz:fix/abstract-method-semicolon
Sep 3, 2026
Merged

dummdidumm merged 4 commits into
sveltejs:mainfrom
leonidaz:fix/abstract-method-semicolon

Conversation

@leonidaz

@leonidaz leonidaz commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Split out of #183 at the maintainers' request.

Abstract methods, abstract accessors and class overload signatures were printed with a trailing space and no semicolon, which is not valid TypeScript:

// before
abstract get a() 
abstract set b(x: string) 

// after
abstract get a();
abstract set b(x: string);
abstract baz(x: string): void;
overloaded(): void;

The method visitor wrote the space before the body unconditionally. It now writes the space only when there is a body and a semicolon otherwise. The existing ts-abstract-class snapshot had recorded the broken output; it is regenerated and extended with an abstract method that has parameters and a return type, and an overload pair.

🤖 Generated with Claude Code

Abstract methods, abstract accessors and overload signatures in classes
were printed with a trailing space and no semicolon (`abstract get a() `),
which is not valid TypeScript. Write `;` when the method has no body
instead of the space that precedes one. The existing abstract-class
snapshot had recorded the broken output.
@pkg-svelte-dev

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

Copy link
Copy Markdown

Install the latest version of esrap from 3e538d1:

pnpm add https://pkg.svelte.dev/esrap/c/3e538d17eef4237e002d5f497106fe4e5f70fdf4

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

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: 3e538d1

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

Comment thread .changeset/abstract-method-semicolon.md Resolved
@dummdidumm
dummdidumm merged commit 17f34a4 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