feat(49786): show completions in expression with type arguments (#49810)

This commit is contained in:
Oleksandr T
2022-07-19 00:55:15 +03:00
committed by GitHub
parent 91f7cfc501
commit 3863cc4a20
2 changed files with 13 additions and 2 deletions

View File

@@ -167,9 +167,9 @@ namespace ts.Completions.StringCompletions {
case SyntaxKind.LiteralType: {
const grandParent = walkUpParentheses(parent.parent);
switch (grandParent.kind) {
case SyntaxKind.ExpressionWithTypeArguments:
case SyntaxKind.TypeReference: {
const typeReference = grandParent as TypeReferenceNode;
const typeArgument = findAncestor(parent, n => n.parent === typeReference) as LiteralTypeNode;
const typeArgument = findAncestor(parent, n => n.parent === grandParent) as LiteralTypeNode;
if (typeArgument) {
return { kind: StringLiteralCompletionKind.Types, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false };
}

View File

@@ -0,0 +1,11 @@
/// <reference path="fourslash.ts" />
////interface I {
//// a: string;
//// b: number;
////}
////type T1 = Pick<I, "/*1*/">;
////interface T2 extends Pick<I, "/*2*/"> {}
verify.completions({ marker: ["1", "2"], exact: ["a", "b"] });