Skip to content

Commit 8ed92dc

Browse files
a-tarasyukOrta
authored andcommitted
fix(31909): show suggestions for second type argument of generic (#36024)
1 parent 88677de commit 8ed92dc

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/services/completions.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,7 @@ namespace ts.Completions {
20772077
switch (contextToken.kind) {
20782078
case SyntaxKind.CommaToken:
20792079
return containingNodeKind === SyntaxKind.VariableDeclaration ||
2080-
containingNodeKind === SyntaxKind.VariableDeclarationList ||
2080+
isVariableDeclarationListButNotTypeArgument(contextToken) ||
20812081
containingNodeKind === SyntaxKind.VariableStatement ||
20822082
containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, |
20832083
isFunctionLikeButNotConstructor(containingNodeKind) ||
@@ -2209,6 +2209,11 @@ namespace ts.Completions {
22092209
return false;
22102210
}
22112211

2212+
function isVariableDeclarationListButNotTypeArgument(node: Node): boolean {
2213+
return node.parent.kind === SyntaxKind.VariableDeclarationList
2214+
&& !isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker);
2215+
}
2216+
22122217
/**
22132218
* Filters out completion suggestions for named imports or exports.
22142219
*
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////class Foo<T1, T2> {}
4+
////const foo = new Foo</*1*/, /*2*/,
5+
////
6+
////function foo<T1, T2>() {}
7+
////const f = foo</*3*/, /*4*/,
8+
9+
verify.completions({ marker: "1", exact: completion.globalTypesPlus(['Foo']) });
10+
verify.completions({ marker: "2", exact: completion.globalTypesPlus(['Foo']) });
11+
verify.completions({ marker: "3", exact: completion.globalTypesPlus(['Foo']) });
12+
verify.completions({ marker: "4", exact: completion.globalTypesPlus(['Foo']) });

0 commit comments

Comments
 (0)