Skip to content

Abstract methods don't correctly compile in .svelte files #15260

@dooshiifox

Description

@dooshiifox

Describe the bug

Compiling an abstract class with an abstract method does not remove the abstract method from the JS output, instead just removing the abstract keyword and all types. This produces a runtime SyntaxError. This only occurs within .svelte components and not in normal TypeScript.

A temporary workaround is to simply remove the abstracts and define a method body that errors, or by extracting the class into a .svelte.ts file where this issue does not occur.

Reproduction

https://svelte.dev/playground/hello-world?version=5.19.9#H4sIAAAAAAAAA22PwW4CMQxEf8XyCSTUvW9ppaqXXvgCQkVI3BLIJlHsQFer_XcS6KGHniy9GY_HEwY9EPb4Qd5HuMbsLSzIOiG7xBV-OU-M_XZCGVPzNVD579ZbSk98IS-NHTTTf9zEIBSkxuCaTXZJwOvw_aJQWCEM0RZPryoo6Tr4BMdcCLTnCNGYkhmuTo6xCOwf1v0KnMCpsMCgz8QgR4ITQ7Wk6jKedKDc8vSBJWvTmGaGzfh-n1PT_qjDuKF6wS6WPVyis89Nn1VYd4-6tVt9Q-hHsJdcaN7NNwmrwrI4AQAA

Logs

System Info

System:
    OS: Linux 6.6 cpe:/o:nixos:nixos:25.05 25.05 (Warbler)
    CPU: (32) x64 13th Gen Intel(R) Core(TM) i9-13900HX
    Memory: 16.25 GB / 31.19 GB
    Container: Yes
    Shell: 5.2.37 - /nix/store/0irlcqx2n3qm6b1pc9rsd2i8qpvcccaj-bash-5.2p37/bin/bash
  Binaries:
    Node: 20.18.0 - /nix/store/z0ivg3dbal4sk5h0c7p1pfkxc7ff98ri-nodejs-20.18.0/bin/node
    npm: 10.8.2 - /nix/store/z0ivg3dbal4sk5h0c7p1pfkxc7ff98ri-nodejs-20.18.0/bin/npm
    pnpm: 9.12.3 - /nix/store/3xd8lpj86wbjkvxd2qjd28fd98gqsypc-pnpm-9.12.3/bin/pnpm
  Browsers:
    Chromium: 131.0.6778.204
  npmPackages:
    svelte: ^5.19.0 => 5.19.8

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions