Skip to content

Commit 048d046

Browse files
author
Benjamin Lichtman
committed
use existing util functions
1 parent bb2f300 commit 048d046

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ namespace ts {
21212121
: undefined;
21222122
}
21232123

2124-
function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node: Node): Expression | undefined {
2124+
export function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node: Node): Expression | undefined {
21252125
switch (node.kind) {
21262126
case SyntaxKind.VariableStatement:
21272127
const v = getSingleVariableOfVariableStatement(node);

src/services/outliningElementsCollector.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ namespace ts.OutliningElementsCollector {
6060
}
6161

6262
function isFunctionExpressionAssignedToVariable(n: Node) {
63-
return (isFunctionExpression(n) || isArrowFunction(n)) &&
64-
n.parent && n.parent.parent && n.parent.parent.parent &&
65-
isVariableStatement(n.parent.parent.parent);
63+
if (!isFunctionExpression(n) && !isArrowFunction(n)) {
64+
return false;
65+
}
66+
const ancestor = findAncestor(n, isVariableStatement);
67+
return !!ancestor && getSingleInitializerOfVariableStatementOrPropertyDeclaration(ancestor) === n;
6668
}
6769
}
6870

0 commit comments

Comments
 (0)