Merge pull request #32382 from dragomirtitian/GH-29769-generic-auto-completion-missing-primitives

Fixed auto completion after a < token to return types not values.
This commit is contained in:
Daniel Rosenwasser 2019-07-15 16:41:03 -07:00 committed by GitHub
commit c7b8b2ae9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 3 deletions

View file

@ -1239,6 +1239,9 @@ namespace ts.Completions {
case SyntaxKind.AsKeyword:
return parentKind === SyntaxKind.AsExpression;
case SyntaxKind.LessThanToken:
return parentKind === SyntaxKind.TypeReference;
case SyntaxKind.ExtendsKeyword:
return parentKind === SyntaxKind.TypeParameter;
}

View file

@ -0,0 +1,12 @@
/// <reference path="fourslash.ts" />
//// function f() {
//// const k: Record</**/
//// }
goTo.marker();
verify.completions({
includes: [
{ name: "string", sortText: completion.SortText.GlobalsOrKeywords }
]
});

View file

@ -10,8 +10,8 @@
////x < {| "valueOnly": true |}
////f < {| "valueOnly": true |}
////g < {| "valueOnly": false |}
////const something: C<{| "valueOnly": false |};
////const something2: C<C<{| "valueOnly": false |};
////const something: C<{| "typeOnly": true |};
////const something2: C<C<{| "typeOnly": true |};
////new C<{| "valueOnly": false |};
////new C<C<{| "valueOnly": false |};
////
@ -20,7 +20,10 @@
////new callAndConstruct<callAndConstruct</*callAndConstruct*/
for (const marker of test.markers()) {
if (marker.data && marker.data.valueOnly) {
if (marker.data && marker.data.typeOnly) {
verify.completions({ marker, includes: "T", excludes: "x" });
}
else if (marker.data && marker.data.valueOnly) {
verify.completions({ marker, includes: "x", excludes: "T" });
}
else {