mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
feat(49786): show completions in expression with type arguments (#49810)
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
|
||||
11
tests/cases/fourslash/completionsAtTypeArguments.ts
Normal file
11
tests/cases/fourslash/completionsAtTypeArguments.ts
Normal 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"] });
|
||||
Reference in New Issue
Block a user