Skip to content

Commit c7b8b2a

Browse files
Merge pull request #32382 from dragomirtitian/GH-29769-generic-auto-completion-missing-primitives
Fixed auto completion after a < token to return types not values.
2 parents 7cdfbce + ba79b5f commit c7b8b2a

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/services/completions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,9 @@ namespace ts.Completions {
12391239
case SyntaxKind.AsKeyword:
12401240
return parentKind === SyntaxKind.AsExpression;
12411241

1242+
case SyntaxKind.LessThanToken:
1243+
return parentKind === SyntaxKind.TypeReference;
1244+
12421245
case SyntaxKind.ExtendsKeyword:
12431246
return parentKind === SyntaxKind.TypeParameter;
12441247
}
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+
//// function f() {
4+
//// const k: Record</**/
5+
//// }
6+
7+
goTo.marker();
8+
verify.completions({
9+
includes: [
10+
{ name: "string", sortText: completion.SortText.GlobalsOrKeywords }
11+
]
12+
});

tests/cases/fourslash/completionsIsPossiblyTypeArgumentPosition.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
////x < {| "valueOnly": true |}
1111
////f < {| "valueOnly": true |}
1212
////g < {| "valueOnly": false |}
13-
////const something: C<{| "valueOnly": false |};
14-
////const something2: C<C<{| "valueOnly": false |};
13+
////const something: C<{| "typeOnly": true |};
14+
////const something2: C<C<{| "typeOnly": true |};
1515
////new C<{| "valueOnly": false |};
1616
////new C<C<{| "valueOnly": false |};
1717
////
@@ -20,7 +20,10 @@
2020
////new callAndConstruct<callAndConstruct</*callAndConstruct*/
2121

2222
for (const marker of test.markers()) {
23-
if (marker.data && marker.data.valueOnly) {
23+
if (marker.data && marker.data.typeOnly) {
24+
verify.completions({ marker, includes: "T", excludes: "x" });
25+
}
26+
else if (marker.data && marker.data.valueOnly) {
2427
verify.completions({ marker, includes: "x", excludes: "T" });
2528
}
2629
else {

0 commit comments

Comments
 (0)