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

This commit is contained in:
Oleksandr T 2023-05-25 02:19:49 +03:00 committed by GitHub
parent 8ea3887f70
commit 8db251fb47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 4 deletions

View File

@ -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 + " * ";

View File

@ -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
*/`);

View File

@ -0,0 +1,7 @@
/// <reference path='fourslash.ts' />
/////** @param p */
/////*/**/
////function foo(p) {}
verify.docCommentTemplateAt("", 3, `/** */`);

View File

@ -9,4 +9,8 @@
/////*/**/
////function foo(p) {}
verify.docCommentTemplateAt("", 3, "/** */");
verify.docCommentTemplateAt("", 7,
`/**
*
* @param p
*/`);