microsoft / microsoft/TypeScript

Double slash comment `//` will be wrongly removed in the trailing position of the object attribute

Open
#56,055 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: Comment Emit Help Wanted Possible Improvement
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔎 Search Terms
  • comment removal
  • removeComments
🕗 Version & Regression Information
  • This is the behavior in every version I tried.
⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.2.2#code/KYDwDg9gTgLgBAYwgOwM7wGYQnAvHAbwCg5S4sIAuOAcgpoBo4B6ZuGACwEtVEIBbfsGTwA7lwA2EuACNgcKMH4QAbsAAmAOhJkZAQyjUa+qDRZtOPPoOFjJ0uXADWwMDCYyArmI4BPbQC+QA

💻 Code
export const foo = {
    foo: 'foo', // this comment will be removed, however this should be kept
    bar: 'bar' // this comment will be kept, works well
}
🙁 Actual behavior
export const foo = {
    foo: 'foo',
    bar: 'bar' // this comment will be kept, works well
}
🙂 Expected behavior
export const foo = {
    foo: 'foo', // this comment will be removed, however this should be kept
    bar: 'bar' // this comment will be kept, works well
}
Additional information about the issue

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the removeComments behavior named in the issue and reproduce the case in the linked TypeScript Playground. Compare comment handling for the trailing object attribute with and without a following comma. Done means the shown foo comment is preserved while the existing bar comment remains unchanged, with a regression test covering the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.