microsoft / microsoft/TypeScript
getTrailingCommentRanges returns comments at the start of the file
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: master
Code:
// one
// two
Expected behavior:
ts.getTrailingCommentRanges(text, 0) doesn't return a comment.
Both comments are parsed by ts.getLeadingCommentRanges(text, 0).
Actual behavior:
ts.getTrailingCommentRanges(text, 0) parses // one as a trailing comment.
ts.getLeadingCommentRanges(text, 0) parses both comments.
The special handling of position 0 should also affect trailing comments.
With the current behavior I have to remember to not parse trailing comment ranges at position 0 to avoid duplicates.
Related Issues:
This was part of https://github.com/Microsoft/TypeScript/pull/28489 where I first proposed changing this behavior.
/cc @rbuckton
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the TypeScript implementation of ts.getTrailingCommentRanges and ts.getLeadingCommentRanges, then review the related change in pull request #28489. Reproduce the behavior using the two-line comment example at position 0 and verify that trailing ranges no longer duplicate comments returned as leading ranges.
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
- 45/100