diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 2e2bc61136a3f..fd9fb932e21ec 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -333,7 +333,8 @@ namespace ts.JsDoc { } const { commentOwner, parameters, hasReturn } = commentOwnerInfo; - if (commentOwner.getStart(sourceFile) < position) { + const commentOwnerJSDoc = hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? lastOrUndefined(commentOwner.jsDoc) : undefined; + if (commentOwner.getStart(sourceFile) < position || commentOwnerJSDoc && commentOwnerJSDoc !== existingDocComment) { return undefined; } diff --git a/tests/cases/fourslash/docCommentTemplateWithExistingJSDoc.ts b/tests/cases/fourslash/docCommentTemplateWithExistingJSDoc.ts new file mode 100644 index 0000000000000..a2dedc929ff05 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateWithExistingJSDoc.ts @@ -0,0 +1,13 @@ +/// + +/////** /**/ */ +//// +/////** +//// * @param {string} a +//// * @param {string} b +//// */ +////function foo(a, b) { +//// return a + b; +////} + +verify.noDocCommentTemplateAt("");