Skip to content

Commit 95690c0

Browse files
authored
fix(38840): omit completions for a spread like argument in a function definition (microsoft#38897)
1 parent 59f8097 commit 95690c0

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

src/services/completions.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -962,12 +962,13 @@ namespace ts.Completions {
962962
case SyntaxKind.PropertyAccessExpression:
963963
propertyAccessToConvert = parent as PropertyAccessExpression;
964964
node = propertyAccessToConvert.expression;
965-
if (node.end === contextToken.pos &&
966-
isCallExpression(node) &&
965+
if ((isCallExpression(node) || isFunctionLike(node)) &&
966+
node.end === contextToken.pos &&
967967
node.getChildCount(sourceFile) &&
968968
last(node.getChildren(sourceFile)).kind !== SyntaxKind.CloseParenToken) {
969-
// This is likely dot from incorrectly parsed call expression and user is starting to write spread
969+
// This is likely dot from incorrectly parsed expression and user is starting to write spread
970970
// eg: Math.min(./**/)
971+
// const x = function (./**/) {}
971972
return undefined;
972973
}
973974
break;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////const t0 = {
4+
//// x: function (./*0*/) {}
5+
////}
6+
////const t1 = {
7+
//// x: (./*1*/) => {}
8+
////}
9+
////const t2 = {
10+
//// x: function foo(./*2*/) => {}
11+
////}
12+
////const t3 = {
13+
//// x(./*3*/) {}
14+
////}
15+
////
16+
////const t4 = function (./*4*/) {}
17+
////const t5 = (./*5*/) => {}
18+
////function t6(./*6*/) {}
19+
////
20+
////class Foo {
21+
//// m(./*7*/) {}
22+
////}
23+
24+
for (const marker of test.markers()) {
25+
goTo.marker(marker);
26+
verify.completions({ exact: undefined });
27+
28+
edit.insert(".");
29+
verify.completions({ exact: undefined });
30+
31+
edit.insert(".");
32+
verify.completions({ exact: undefined });
33+
}

0 commit comments

Comments
 (0)