From 34970d8a692f9532af2aff146558f81e94c1cd8f Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Mon, 31 Dec 2018 15:10:22 -0800 Subject: [PATCH] give jsdoc outline span before func exp assigned to var --- src/services/outliningElementsCollector.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 5e3ab31c46a..3f4d345be8c 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -37,6 +37,10 @@ namespace ts.OutliningElementsCollector { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } + if (isFunctionExpressionAssignedToVariable(n)) { + addOutliningForLeadingCommentsForNode(n.parent.parent.parent, sourceFile, cancellationToken, out); + } + const span = getOutliningSpanForNode(n, sourceFile); if (span) out.push(span); @@ -54,6 +58,12 @@ namespace ts.OutliningElementsCollector { } depthRemaining++; } + + function isFunctionExpressionAssignedToVariable(n: Node) { + return (isFunctionExpression(n) || isArrowFunction(n)) && + n.parent && n.parent.parent && n.parent.parent.parent && + isVariableStatement(n.parent.parent.parent); + } } function addRegionOutliningSpans(sourceFile: SourceFile, out: Push): void {