From 51881c4ea22583890c2d3daddfcc798c6df6665d Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Mon, 23 Aug 2021 17:34:47 -0700 Subject: [PATCH] Filter out empty access expression --- src/services/completions.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index 285095e727a0c..1f987c0dec1fd 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1338,13 +1338,16 @@ namespace ts.Completions { case SyntaxKind.PropertyAccessExpression: propertyAccessToConvert = parent as PropertyAccessExpression; node = propertyAccessToConvert.expression; - if ((isCallExpression(node) || isFunctionLike(node)) && - node.end === contextToken.pos && - node.getChildCount(sourceFile) && - last(node.getChildren(sourceFile)).kind !== SyntaxKind.CloseParenToken) { + const leftMostAccessExpression = getLeftmostAccessExpression(parent as Expression); + if (leftMostAccessExpression.pos === leftMostAccessExpression.end || + ((isCallExpression(node) || isFunctionLike(node)) && + node.end === contextToken.pos && + node.getChildCount(sourceFile) && + last(node.getChildren(sourceFile)).kind !== SyntaxKind.CloseParenToken)) { // This is likely dot from incorrectly parsed expression and user is starting to write spread // eg: Math.min(./**/) // const x = function (./**/) {} + // ({./**/}) return undefined; } break;