Skip to content

Losing the abstract keyword declared in the functions in anonymus class. #453

@lotexiu

Description

@lotexiu

Describe the bug

When using Vite to build a library with an anonymous abstract class inside a function, the abstract keyword may be lost in the output .d.ts file. This can lead to a situation where it appears that the method is already implemented, even though it should not be. Consider defining the class outside of the function or using a named abstract class to retain the abstract keyword in the generated TypeScript definitions.

Reproduction

https://stackblitz.com/edit/sb1-zwpa78c3?file=vite.config.ts

Steps to reproduce

Run pnpm install and pnpm build.
You're going to be able to see d.ts in the dist folder.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (6) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vite: ^5.4.2 => 5.4.21 
    vite-plugin-dts: ^4.5.4 => 4.5.4

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions