Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for type parameters on original type when getting type argument completions #46614

Merged
merged 3 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34729,7 +34729,8 @@ namespace ts {
function getTypeArgumentConstraint(node: TypeNode): Type | undefined {
const typeReferenceNode = tryCast(node.parent, isTypeReferenceType);
if (!typeReferenceNode) return undefined;
const typeParameters = getTypeParametersForTypeReference(typeReferenceNode)!; // TODO: GH#18217
const typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
if (!typeParameters) return undefined;
const constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments!.indexOf(node)]);
return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference path="./fourslash.ts" />

////interface Foo {}
////type Bar = {};
////
////let x: Foo<"/*1*/">;
////let y: Bar<"/*2*/">;

verify.completions({ marker: test.markers() });


DanielRosenwasser marked this conversation as resolved.
Show resolved Hide resolved