Skip to content

At starts jsdoc tag only after whitespace #42364

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

Merged
merged 2 commits into from
Jan 25, 2021

Conversation

sandersn
Copy link
Member

Previously, inside a JSDoc tag's comment, @ would start a tag unless it was surrounded by backticks. However, looking at real code showed that only whitespace-preceded uses of @ were intended to start tags.

Please suggest new test cases if you can think of them. I feel like there are not quite enough.

Discussion

Why add a boolean flag as context instead of more states?

Whitespace parsing applies to all four states and doesn't currently change states. Correctly representing was-previous-character-whitespace would require doubling the state space. For example, I would have split SavingComments into SavingCommentsNoWhitespace and SavingCommentsPreviousWhitespace. The code would have lots more transitions to worry about as well. I decided representing the decision as a single context boolean was simpler.

Why doesn't top-level parsing change?

Top-level parsing already behaves the way strict JSDoc parsers do -- anything preceding the first @ except (1) start of comment or (2) newline plus optional asterisk causes the @ to be treated as a comment.

Nobody's complained about this much!

Fixes #39371

Previously, inside a JSDoc tag's comment, @ would start a tag unless it
was surrounded by backticks. However, looking at real code showed that
only whitespace-preceded uses of @ were intended to start tags.
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jan 15, 2021
@sandersn
Copy link
Member Author

ping @andrewbranch @armanio123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

@example breaks when example includes @ character (org package imports)
3 participants