From 058024e8ab19a16485d7f3e125601d63aa5bfb04 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sat, 5 Feb 2022 19:04:39 +0200 Subject: [PATCH] fix(47733): omit JSDoc comment template suggestion on node with existing JSDoc --- src/services/jsDoc.ts | 3 ++- .../docCommentTemplateWithExistingJSDoc.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/docCommentTemplateWithExistingJSDoc.ts 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("");