Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emitIsolatedDts fails to preserve subsequent function declaration after abstract function conversion #9656

Closed
mingc00 opened this issue Oct 17, 2024 · 1 comment · Fixed by #9678
Labels
Milestone

Comments

@mingc00
Copy link

mingc00 commented Oct 17, 2024

Describe the bug

When using the emitIsolatedDts option, the subsequent function declaration following an abstract function disappears from the generated .d.ts file. This issue occurs consistently when a function is marked as abstract.

Steps to reproduce:

$ git clone https://github.com/mingc00/swc-dts-bug.git
$ pnpm build
$ cat dist/index.d.ts

Input code

export abstract class Manager {
  protected abstract A(): void;
  
  protected B(): void {
    console.log('B');
  }

  protected C(): void {
    console.log('B');
  }
}

Config

{
  "$schema": "https://swc.rs/schema.json",
  "jsc": {
    "loose": true,
    "parser": {
      "syntax": "typescript"
    },
    "experimental": {
      "emitIsolatedDts": true
    },
    "target": "es2022"
  }
}

Playground link (or link to the minimal reproduction)

https://github.com/mingc00/swc-dts-bug

SWC Info output

Node.js v20.17.0

Operating System:
    Platform: linux
    Arch: x64
    Machine Type: x86_64
    Version: #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024
    CPU: (8 cores)
        Models: Intel(R) Xeon(R) Silver 4214R CPU @ 2.40GHz

Binaries:
    Node: 20.17.0
    npm: 10.8.2
    Yarn: N/A
    pnpm: 9.12.2

Relevant Packages:
    @swc/core: 1.7.36
    @swc/helpers: N/A
    @swc/types: N/A


SWC Config:
    output: N/A
    .swcrc path: N/A

Next.js info:
    output: N/A

Expected behavior

index.d.ts should be

export declare abstract class Manager {
    protected abstract A(): void;
    protected B(): void;
    protected C(): void;
}

Actual behavior

export declare abstract class Manager {
    protected abstract A(): void;
    protected C(): void;
}

Version

1.7.36

Additional context

No response

@swc-bot
Copy link
Collaborator

swc-bot commented Nov 25, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants