From 22eb519b0f6c4c06c71a7c2dd351bbec530f5dd9 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 27 Oct 2017 15:33:30 -0700 Subject: [PATCH] Return empty doc comment instead of undefined --- src/services/jsDoc.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 3e9913fc6c7..49f13d0b4c3 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -188,24 +188,26 @@ namespace ts.JsDoc { * be performed. */ export function getDocCommentTemplateAtPosition(newLine: string, sourceFile: SourceFile, position: number): TextInsertion { + const emptyDocComment = { newText: "", caretOffset: 0 }; + // Check if in a context where we don't want to perform any insertion if (isInString(sourceFile, position) || isInComment(sourceFile, position) || hasDocComment(sourceFile, position)) { - return undefined; + return emptyDocComment; } const tokenAtPos = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); const tokenStart = tokenAtPos.getStart(); if (!tokenAtPos || tokenStart < position) { - return undefined; + return emptyDocComment; } const commentOwnerInfo = getCommentOwnerInfo(tokenAtPos); if (!commentOwnerInfo) { - return undefined; + return emptyDocComment; } const { commentOwner, parameters } = commentOwnerInfo; if (commentOwner.getStart() < position) { - return undefined; + return emptyDocComment; } const posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position);