Skip to content

getTrailingCommentRanges returns comments at the start of the file #29625

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

Open
ajafff opened this issue Jan 28, 2019 · 0 comments
Open

getTrailingCommentRanges returns comments at the start of the file #29625

ajafff opened this issue Jan 28, 2019 · 0 comments
Labels
API Relates to the public API for TypeScript In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@ajafff
Copy link
Contributor

ajafff commented Jan 28, 2019

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 #28489 where I first proposed changing this behavior.

/cc @rbuckton

@weswigham weswigham added Suggestion An idea for TypeScript In Discussion Not yet reached consensus API Relates to the public API for TypeScript labels Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Relates to the public API for TypeScript In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants