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:
commit
c7b8b2ae9b
3 changed files with 21 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
12
tests/cases/fourslash/completionsAfterLessThanToken.ts
Normal file
12
tests/cases/fourslash/completionsAfterLessThanToken.ts
Normal 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 }
|
||||
]
|
||||
});
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue