Skip to content

Commit 51881c4

Browse files
committed
Filter out empty access expression
1 parent e1a2b9e commit 51881c4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/services/completions.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1338,13 +1338,16 @@ namespace ts.Completions {
13381338
case SyntaxKind.PropertyAccessExpression:
13391339
propertyAccessToConvert = parent as PropertyAccessExpression;
13401340
node = propertyAccessToConvert.expression;
1341-
if ((isCallExpression(node) || isFunctionLike(node)) &&
1342-
node.end === contextToken.pos &&
1343-
node.getChildCount(sourceFile) &&
1344-
last(node.getChildren(sourceFile)).kind !== SyntaxKind.CloseParenToken) {
1341+
const leftMostAccessExpression = getLeftmostAccessExpression(parent as Expression);
1342+
if (leftMostAccessExpression.pos === leftMostAccessExpression.end ||
1343+
((isCallExpression(node) || isFunctionLike(node)) &&
1344+
node.end === contextToken.pos &&
1345+
node.getChildCount(sourceFile) &&
1346+
last(node.getChildren(sourceFile)).kind !== SyntaxKind.CloseParenToken)) {
13451347
// This is likely dot from incorrectly parsed expression and user is starting to write spread
13461348
// eg: Math.min(./**/)
13471349
// const x = function (./**/) {}
1350+
// ({./**/})
13481351
return undefined;
13491352
}
13501353
break;

0 commit comments

Comments
 (0)