Skip to content

Commit

Permalink
Cherry-pick PR #45484 into release-4.4 (#45564)
Browse files Browse the repository at this point in the history
Component commits:
33829fa Fix and updated tests

2249d6c Added test

e1a2b9e Revert "Fix and updated tests"
This reverts commit 33829fa.

51881c4 Filter out empty access expression

2253da6 PR feedback

Co-authored-by: Armando Aguirre <[email protected]>
  • Loading branch information
TypeScript Bot and armanio123 authored Aug 30, 2021
1 parent 9eb689e commit 782c09d
Show file tree
Hide file tree
Showing 2 changed files with 19 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(propertyAccessToConvert);
if (nodeIsMissing(leftmostAccessExpression) ||
((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
12 changes: 12 additions & 0 deletions tests/cases/fourslash/getJavaScriptCompletions22.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path="fourslash.ts" />

// Regresion test for GH#45436

// @allowNonTsExtensions: true
// @Filename: file.js
//// const abc = {};
//// ({./*1*/});

goTo.marker('1');
edit.insert('.');
verify.completions({ exact: undefined });

0 comments on commit 782c09d

Please sign in to comment.