Skip to content
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

fix(52517): JSDoc Comment Template not provided when unrelated JSDoc with tag exists #54132

Merged
merged 3 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/services/jsDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,7 @@ export function getDocCommentTemplateAtPosition(newLine: string, sourceFile: Sou
// * if the caret was directly in front of the object, then we add an extra line and indentation.
const openComment = "/**";
const closeComment = " */";

// If any of the existing jsDoc has tags, ignore adding new ones.
const hasTag = (commentOwnerJsDoc || []).some(jsDoc => !!jsDoc.tags);
const hasTag = length(getJSDocTags(commentOwner)) > 0;

if (tags && !hasTag) {
const preamble = openComment + newLine + indentationStr + " * ";
Expand Down
14 changes: 14 additions & 0 deletions tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// <reference path='fourslash.ts' />

/////** @typedef {string} Id */
////
/////** /**/ */
////function foo(x, y, z) {}

verify.docCommentTemplateAt("", 7,
`/**
*
* @param x
* @param y
* @param z
*/`);
7 changes: 7 additions & 0 deletions tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference path='fourslash.ts' />

/////** @param p */
/////*/**/
a-tarasyuk marked this conversation as resolved.
Show resolved Hide resolved
////function foo(p) {}

verify.docCommentTemplateAt("", 3, `/** */`);
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
/////*/**/
////function foo(p) {}

verify.docCommentTemplateAt("", 3, "/** */");
a-tarasyuk marked this conversation as resolved.
Show resolved Hide resolved
verify.docCommentTemplateAt("", 7,
`/**
*
* @param p
*/`);