Skip to content

Commit d9ab307

Browse files
committed
feat: check node.parent exist first
1 parent 5c2e314 commit d9ab307

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/services/completions.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1542,8 +1542,13 @@ namespace ts.Completions {
15421542
}
15431543

15441544
function getVariableDeclaration(property: Node): VariableDeclaration | undefined {
1545+
1546+
const isArrowFunctionExpressionWithoutArrow = (node: Node) => {
1547+
return node.parent && isArrowFunction(node.parent) && node.parent.body === node;
1548+
};
1549+
15451550
const variableDeclaration = findAncestor(property, (node) => {
1546-
if (isFunctionBlock(node) || isBindingPattern(node) || (isArrowFunction(node.parent) && node.parent.body === node)) {
1551+
if (isFunctionBlock(node) || isArrowFunctionExpressionWithoutArrow(node) || isBindingPattern(node)) {
15471552
return "quit";
15481553
}
15491554

0 commit comments

Comments
 (0)