mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-12 04:17:34 -06:00
fix(31909): show suggestions for second type argument of generic (#36024)
This commit is contained in:
parent
88677de380
commit
8ed92dcecd
@ -2077,7 +2077,7 @@ namespace ts.Completions {
|
||||
switch (contextToken.kind) {
|
||||
case SyntaxKind.CommaToken:
|
||||
return containingNodeKind === SyntaxKind.VariableDeclaration ||
|
||||
containingNodeKind === SyntaxKind.VariableDeclarationList ||
|
||||
isVariableDeclarationListButNotTypeArgument(contextToken) ||
|
||||
containingNodeKind === SyntaxKind.VariableStatement ||
|
||||
containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, |
|
||||
isFunctionLikeButNotConstructor(containingNodeKind) ||
|
||||
@ -2209,6 +2209,11 @@ namespace ts.Completions {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isVariableDeclarationListButNotTypeArgument(node: Node): boolean {
|
||||
return node.parent.kind === SyntaxKind.VariableDeclarationList
|
||||
&& !isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out completion suggestions for named imports or exports.
|
||||
*
|
||||
|
||||
12
tests/cases/fourslash/completionsAtGenericTypeArguments.ts
Normal file
12
tests/cases/fourslash/completionsAtGenericTypeArguments.ts
Normal file
@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class Foo<T1, T2> {}
|
||||
////const foo = new Foo</*1*/, /*2*/,
|
||||
////
|
||||
////function foo<T1, T2>() {}
|
||||
////const f = foo</*3*/, /*4*/,
|
||||
|
||||
verify.completions({ marker: "1", exact: completion.globalTypesPlus(['Foo']) });
|
||||
verify.completions({ marker: "2", exact: completion.globalTypesPlus(['Foo']) });
|
||||
verify.completions({ marker: "3", exact: completion.globalTypesPlus(['Foo']) });
|
||||
verify.completions({ marker: "4", exact: completion.globalTypesPlus(['Foo']) });
|
||||
Loading…
x
Reference in New Issue
Block a user