Skip to content

Commit

Permalink
Filter out empty access expression
Browse files Browse the repository at this point in the history
  • Loading branch information
armanio123 committed Aug 24, 2021
1 parent e1a2b9e commit 51881c4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 51881c4

Please sign in to comment.