microsoft / microsoft/TypeScript
Trivia ownership documentation seems to be incorrect
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
Acknowledgement
- I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.
Comment
Referencing the #1678 issue and the ast-trivia: trivia ownership in the typescript-book, there seems to be an error in explanation:
in the issue @mhegazy mentions:
one thing that is different from the Roslyn notion of trivia, is we do not have trailing trivia. all triva in TypeScript is leading. so for instance [...]
in the same issue and in the wiki book however the following info is given:
In General:
- A token owns any trivia after it on the same line upto the next token.
- Any comment after that line is associated with the following token.
So from the first cite I understand as if token owns any trivia before it up to the previous token ([trivia of A][token A]... that's why end-of-file token is always present) which seems to be the correct explanation, while the second cite describes that a token owns the trivia after it up to next token in the same line, which would mean that A has trailing trivia, thus not true in TS — albeit true for Roslyn.
[token A][trivia owned by A]<nl>
[trivia owned by B]
[token B]
Unless there is some misconception of what "owned" trivia means, but imo the second cite is incorrect.
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
Open docs/compiler/ast-trivia.md at the “trivia ownership” section and compare its wording with issue #1678 and the cited TypeScript behavior. Update the explanation so ownership is consistent with the leading-trivia model described in the issue, then verify that the included examples no longer imply trailing trivia.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100