From 1545ab56f3e4afbbbbdaef4a05ffa0cc76f1a4e4 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 24 Sep 2015 14:58:12 -0700 Subject: [PATCH] Use a loop because reduce is unreadable. --- src/services/services.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 87cca1fe0f1..90885043720 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -7030,6 +7030,7 @@ namespace ts { // - class decls let containingFunction = getAncestor(tokenAtPos, SyntaxKind.FunctionDeclaration); + if (!containingFunction || containingFunction.getStart() < position) { return undefined; } @@ -7043,9 +7044,15 @@ namespace ts { // TODO: call a helper method instead once PR #4133 gets merged in. const newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - let docParams = parameters.reduce((prev, cur, index) => - prev + - indentationStr + " * @param " + (cur.name.kind === SyntaxKind.Identifier ? (cur.name).text : "param" + index) + newLine, ""); + let docParams = ""; + for (let i = 0, numParams = parameters.length; i < numParams; i++) { + const currentName = parameters[i].name; + const paramName = currentName.kind === SyntaxKind.Identifier ? + (currentName).text : + "param" + i; + + docParams += `${indentationStr} * @param ${paramName}${newLine}`; + } // A doc comment consists of the following // * The opening comment line