Skip to content

Commit 6d33d87

Browse files
Check for type parameters on original type when getting type argument completions (#46614)
* Add failing test. * Check for type parameters on the original type when asking for the type argument constraint. * Update tests/cases/fourslash/stringLiteralTypeCompletionsInTypeArgForNonGeneric1.ts
1 parent bf6d164 commit 6d33d87

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34729,7 +34729,8 @@ namespace ts {
3472934729
function getTypeArgumentConstraint(node: TypeNode): Type | undefined {
3473034730
const typeReferenceNode = tryCast(node.parent, isTypeReferenceType);
3473134731
if (!typeReferenceNode) return undefined;
34732-
const typeParameters = getTypeParametersForTypeReference(typeReferenceNode)!; // TODO: GH#18217
34732+
const typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
34733+
if (!typeParameters) return undefined;
3473334734
const constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments!.indexOf(node)]);
3473434735
return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
3473534736
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path="./fourslash.ts" />
2+
3+
////interface Foo {}
4+
////type Bar = {};
5+
////
6+
////let x: Foo<"/*1*/">;
7+
////let y: Bar<"/*2*/">;
8+
9+
verify.completions({ marker: test.markers() });
10+

0 commit comments

Comments
 (0)