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

swc.transform with experimental.emitIsolatedDts does not include comments in the output with preserveAllComments: true #9550

Closed
MillanWangGadget opened this issue Sep 11, 2024 · 3 comments · Fixed by #9572
Assignees
Labels
Milestone

Comments

@MillanWangGadget
Copy link

Describe the bug

swc.transform with experimental.emitIsolatedDts does not include comments in the output with preserveAllComments: true

Ideally, JSDoc comments could be preserved in the .d.ts output file

Input code

const result = await swc.transform(fullTextFromFile, {
  filename: filePath,
  jsc: {
    parser: {
      syntax: "typescript",
      tsx: true,
    },
    preserveAllComments: true, // Does not include comments in the emitted file
    experimental: {
      emitIsolatedDts: true,
    },
  },
});

Config

No response

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.7.25&code=H4sIAAAAAAAAA02OMQ7CMAxF95zij1AB3cvCgJBg7QmckNIg4lSJow5V704oHTr6P%2Ft911WlUKElP3wsHu01GEhPgjtGl3qMlOC4RBZpNCeJxKkL0SNkGbL8bi8DRfIgHJEkOn5hCTZIF8TZaxs3KFrJkVNBQb%2BtkdInfbEQP6HLRq26zEZcYKTlu1sZd9SsJQfoZpXuMSng78MEKgjzWc3qC9n9%2B5rdAAAA&config=H4sIAAAAAAAAA1WPSw7DIAwF9zkF8rrbdtE79BCIOhERP9mOVBTl7oUE0maH3xszsA5KwcwGnmotxzIkTYx0ziXhHER%2FSgKSE7IhmwRuvRWu1agd4x5tRwOiaUKpW8j3hoOLkbHjLfM22DH%2FC030iZD5ClZUh8nhVTc0Jfj4XvayfaQ%2B9tA%2F4Ad12XkxWH71TaEFh%2B0LYuVI0xQBAAA%3D

SWC Info output

No response

Expected behavior

The comments from the source file text to be included in the output

Actual behavior

No response

Version

"1.7.23"

Additional context

No response

@airhorns
Copy link

Looks like oxc also doesn't get the comments but is planning to fix it: oxc-project/oxc#5687

@airhorns
Copy link

Just to weigh in a little to help prioritize -- without comments, the emitIsolatedDts feature is not super useful in its current form. I think anyone building .d.ts files for consumption intends for them to be consumed by humans, like .d.ts files within node modules that power typechecking and autocomplete. Stripping all the nice documentation or explanation about these files makes those artifacts far far less useful for humans, and much different than the ones that the TypeScript compiler itself would produce.

I know this is probably a super annoying and invasive change to make to swc but as someone who adopted and then had to un-adopt the emitIsolatedDts experiment because of this missing piece, it'd be really great to get actual drop in compatibility with tsc! Also, I know it's marked experimental so no unfair expectations over here, just wanted to share.

@kdy1 kdy1 self-assigned this Sep 15, 2024
@kdy1 kdy1 added this to the Planned milestone Sep 15, 2024
@kdy1 kdy1 closed this as completed in 6d15d9c Sep 20, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.7.28 Sep 24, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 24, 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 Oct 24, 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.

4 participants