Fixed auto completion after a < token to return types not values.

This commit is contained in:
Titian Cernicova-Dragomir 2019-07-12 23:14:42 +03:00
parent 37f2e5972f
commit ba79b5ffac
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 {