Skip to content

Fix bug: Include comment for @param tag with nested tag #23276

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
2 commits merged into from
Apr 9, 2018
Merged

Conversation

ghost
Copy link

@ghost ghost commented Apr 9, 2018

Fixes #23221 (comment)

parseChildParameterOrPropertyTag contains code to skip ahead to the next line -- this means that the comment goes missing. We should probably never skip a comment, but that would be a bigger change than this.

@ghost ghost requested a review from sandersn April 9, 2018 18:25
@ghost ghost force-pushed the paramComment branch from 2d82417 to 68cd97a Compare April 9, 2018 18:25
@ghost ghost force-pushed the paramComment branch from 68cd97a to 9a2458e Compare April 9, 2018 18:26
Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of questions about the change and its tests.

@@ -6526,6 +6526,8 @@ namespace ts {
const result = target === PropertyLikeParse.Parameter ?
<JSDocParameterTag>createNode(SyntaxKind.JSDocParameterTag, atToken.pos) :
<JSDocPropertyTag>createNode(SyntaxKind.JSDocPropertyTag, atToken.pos);
let comment: string | undefined;
if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only nested @params were missing comments before this change, where was the comment parsed for non-nested ones? Does this change now parse the comments for all @params here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, previously it was always done at the bottom of parseTag. But that didn't work if the comment had already been skipped.

parsesCorrectly("Nested @param tags",
`/**
* @param {object} o Doc doc
* @param {string} o.f
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was the comments on nested @param that were incorrectly skipped. Shouldn’t this test include some comments for this line too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseChildParameterOrPropertyTag begins by skipping a line. So it's the comment that comes before the child that was skipped. But I'll add some comments for that line too.

@ghost ghost force-pushed the paramComment branch from 84d39db to 67cd3ff Compare April 9, 2018 20:49
@ghost ghost merged commit 71b3901 into master Apr 9, 2018
@ghost ghost deleted the paramComment branch April 9, 2018 21:10
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant